From 77577c716c650bdf85e4d5317f07459083e24be9 Mon Sep 17 00:00:00 2001 From: Oracle Public Cloud User Date: Thu, 25 Jun 2020 22:28:41 +0000 Subject: [PATCH] Releasing version 2.2.0 --- CHANGELOG.md | 20 + MigrationGuide.md | 24 + README.md | 14 +- UserGuide.md | 5 +- galaxy.yml | 2 +- .../oracle_creatable_resource.py | 4 +- plugins/module_utils/oci_common_utils.py | 39 +- .../oci_compute_custom_helpers.py | 37 +- .../oci_compute_management_custom_helpers.py | 36 - .../oci_container_engine_custom_helpers.py | 29 +- .../module_utils/oci_custom_helpers_utils.py | 74 ++ .../oci_database_custom_helpers.py | 71 +- .../module_utils/oci_dns_custom_helpers.py | 123 ++ .../oci_file_storage_custom_helpers.py | 26 - .../oci_functions_custom_helpers.py | 55 + .../oci_identity_custom_helpers.py | 45 +- .../oci_key_management_custom_helpers.py | 27 - ...s.py => oci_marketplace_custom_helpers.py} | 30 +- .../oci_monitoring_custom_helpers.py | 73 ++ .../oci_network_custom_helpers.py | 79 ++ .../module_utils/oci_ons_custom_helpers.py | 25 + plugins/module_utils/oci_resource_utils.py | 224 ++-- .../oci_streaming_custom_helpers.py | 45 + plugins/module_utils/oci_version.py | 2 +- plugins/module_utils/oci_wait_utils.py | 30 + plugins/modules/oci_audit_configuration.py | 7 +- .../modules/oci_audit_configuration_facts.py | 5 +- plugins/modules/oci_audit_event_facts.py | 5 +- ..._autoscaling_auto_scaling_configuration.py | 32 +- ...caling_auto_scaling_configuration_facts.py | 5 +- ...aling_auto_scaling_configuration_policy.py | 32 +- ...auto_scaling_configuration_policy_facts.py | 5 +- .../modules/oci_blockstorage_boot_volume.py | 29 +- .../oci_blockstorage_boot_volume_backup.py | 33 +- ...blockstorage_boot_volume_backup_actions.py | 8 +- ...i_blockstorage_boot_volume_backup_facts.py | 5 +- .../oci_blockstorage_boot_volume_facts.py | 5 +- .../oci_blockstorage_boot_volume_kms_key.py | 7 +- ..._blockstorage_boot_volume_kms_key_facts.py | 5 +- plugins/modules/oci_blockstorage_volume.py | 33 +- .../modules/oci_blockstorage_volume_backup.py | 33 +- .../oci_blockstorage_volume_backup_actions.py | 8 +- .../oci_blockstorage_volume_backup_facts.py | 5 +- .../oci_blockstorage_volume_backup_policy.py | 34 +- ...storage_volume_backup_policy_assignment.py | 29 +- ...e_volume_backup_policy_assignment_facts.py | 5 +- ...blockstorage_volume_backup_policy_facts.py | 5 +- .../modules/oci_blockstorage_volume_facts.py | 5 +- .../modules/oci_blockstorage_volume_group.py | 33 +- .../oci_blockstorage_volume_group_backup.py | 33 +- ..._blockstorage_volume_group_backup_facts.py | 5 +- .../oci_blockstorage_volume_group_facts.py | 5 +- .../oci_blockstorage_volume_kms_key.py | 7 +- .../oci_blockstorage_volume_kms_key_facts.py | 5 +- plugins/modules/oci_budget.py | 32 +- plugins/modules/oci_budget_alert_rule.py | 32 +- .../modules/oci_budget_alert_rule_facts.py | 5 +- plugins/modules/oci_budget_facts.py | 5 +- .../oci_compute_app_catalog_listing_facts.py | 5 +- ...isting_resource_version_agreement_facts.py | 5 +- ..._catalog_listing_resource_version_facts.py | 5 +- .../oci_compute_app_catalog_subscription.py | 32 +- ..._compute_app_catalog_subscription_facts.py | 5 +- .../oci_compute_boot_volume_attachment.py | 33 +- ...ci_compute_boot_volume_attachment_facts.py | 5 +- .../modules/oci_compute_dedicated_vm_host.py | 33 +- .../oci_compute_dedicated_vm_host_facts.py | 5 +- ...ompute_dedicated_vm_host_instance_facts.py | 5 +- ..._dedicated_vm_host_instance_shape_facts.py | 167 +++ ...i_compute_dedicated_vm_host_shape_facts.py | 166 +++ plugins/modules/oci_compute_device_facts.py | 5 +- plugins/modules/oci_compute_image.py | 38 +- plugins/modules/oci_compute_image_actions.py | 8 +- plugins/modules/oci_compute_image_facts.py | 5 +- ...compute_image_shape_compatibility_entry.py | 86 +- ...e_image_shape_compatibility_entry_facts.py | 196 ++++ plugins/modules/oci_compute_instance.py | 33 +- .../modules/oci_compute_instance_actions.py | 5 +- ...oci_compute_instance_console_connection.py | 32 +- ...mpute_instance_console_connection_facts.py | 5 +- .../oci_compute_instance_console_history.py | 32 +- ..._instance_console_history_content_facts.py | 5 +- ..._compute_instance_console_history_facts.py | 5 +- .../oci_compute_instance_credentials_facts.py | 5 +- plugins/modules/oci_compute_instance_facts.py | 5 +- .../oci_compute_management_cluster_network.py | 32 +- ...ompute_management_cluster_network_facts.py | 5 +- ...nagement_cluster_network_instance_facts.py | 5 +- ...mpute_management_instance_configuration.py | 29 +- ...nagement_instance_configuration_actions.py | 8 +- ...management_instance_configuration_facts.py | 5 +- .../oci_compute_management_instance_pool.py | 32 +- ...ompute_management_instance_pool_actions.py | 13 +- ..._compute_management_instance_pool_facts.py | 5 +- ...management_instance_pool_instance_facts.py | 5 +- ...nce_pool_load_balancer_attachment_facts.py | 5 +- plugins/modules/oci_compute_shape_facts.py | 5 +- .../modules/oci_compute_vnic_attachment.py | 32 +- .../oci_compute_vnic_attachment_facts.py | 5 +- .../modules/oci_compute_volume_attachment.py | 33 +- .../oci_compute_volume_attachment_facts.py | 5 +- .../modules/oci_container_engine_cluster.py | 60 +- .../oci_container_engine_cluster_facts.py | 20 +- ..._container_engine_cluster_options_facts.py | 5 +- .../oci_container_engine_kubeconfig.py | 19 +- .../modules/oci_container_engine_node_pool.py | 112 +- .../oci_container_engine_node_pool_facts.py | 53 +- ...ontainer_engine_node_pool_options_facts.py | 41 +- ..._database_autonomous_container_database.py | 57 +- ...e_autonomous_container_database_actions.py | 25 +- ...ase_autonomous_container_database_facts.py | 5 +- .../oci_database_autonomous_database.py | 48 +- ...ci_database_autonomous_database_actions.py | 15 +- ...oci_database_autonomous_database_backup.py | 35 +- ...tabase_autonomous_database_backup_facts.py | 5 +- .../oci_database_autonomous_database_facts.py | 5 +- ...ase_autonomous_database_regional_wallet.py | 7 +- ...tonomous_database_regional_wallet_facts.py | 5 +- ...oci_database_autonomous_database_wallet.py | 7 +- ...tabase_autonomous_database_wallet_facts.py | 5 +- ...ase_autonomous_db_preview_version_facts.py | 5 +- ...ci_database_autonomous_db_version_facts.py | 5 +- ...abase_autonomous_exadata_infrastructure.py | 58 +- ...autonomous_exadata_infrastructure_facts.py | 5 +- ...mous_exadata_infrastructure_shape_facts.py | 5 +- plugins/modules/oci_database_backup.py | 35 +- plugins/modules/oci_database_backup_facts.py | 5 +- .../oci_database_data_guard_association.py | 440 ++++++++ ...database_data_guard_association_actions.py | 388 +++++++ ...i_database_data_guard_association_facts.py | 279 +++++ plugins/modules/oci_database_database.py | 27 +- .../modules/oci_database_database_actions.py | 8 +- .../modules/oci_database_database_facts.py | 5 +- plugins/modules/oci_database_db_home.py | 38 +- plugins/modules/oci_database_db_home_facts.py | 5 +- .../oci_database_db_home_patch_facts.py | 5 +- ...abase_db_home_patch_history_entry_facts.py | 5 +- .../modules/oci_database_db_node_actions.py | 5 +- plugins/modules/oci_database_db_node_facts.py | 5 +- plugins/modules/oci_database_db_system.py | 45 +- .../modules/oci_database_db_system_facts.py | 9 +- .../oci_database_db_system_patch_facts.py | 5 +- ...ase_db_system_patch_history_entry_facts.py | 5 +- .../oci_database_db_system_shape_facts.py | 5 +- .../modules/oci_database_db_version_facts.py | 5 +- .../modules/oci_database_maintenance_run.py | 34 +- .../oci_database_maintenance_run_facts.py | 5 +- plugins/modules/oci_dns_domain_records.py | 446 ++++++++ .../modules/oci_dns_domain_records_facts.py | 255 +++++ plugins/modules/oci_dns_rrset.py | 466 ++++++++ plugins/modules/oci_dns_rrset_facts.py | 245 ++++ plugins/modules/oci_dns_steering_policy.py | 1003 +++++++++++++++++ .../oci_dns_steering_policy_attachment.py | 395 +++++++ ...ci_dns_steering_policy_attachment_facts.py | 343 ++++++ .../modules/oci_dns_steering_policy_facts.py | 585 ++++++++++ plugins/modules/oci_dns_tsig_key.py | 403 +++++++ plugins/modules/oci_dns_tsig_key_facts.py | 299 +++++ plugins/modules/oci_dns_zone.py | 592 ++++++++++ plugins/modules/oci_dns_zone_facts.py | 412 +++++++ plugins/modules/oci_dns_zone_records.py | 401 +++++++ plugins/modules/oci_dns_zone_records_facts.py | 261 +++++ plugins/modules/oci_email_sender.py | 327 ++++++ plugins/modules/oci_email_sender_facts.py | 258 +++++ plugins/modules/oci_email_suppression.py | 271 +++++ .../modules/oci_email_suppression_facts.py | 249 ++++ plugins/modules/oci_file_storage_export.py | 35 +- .../modules/oci_file_storage_export_facts.py | 5 +- .../modules/oci_file_storage_export_set.py | 32 +- .../oci_file_storage_export_set_facts.py | 5 +- .../modules/oci_file_storage_file_system.py | 32 +- .../oci_file_storage_file_system_facts.py | 5 +- .../modules/oci_file_storage_mount_target.py | 32 +- .../oci_file_storage_mount_target_facts.py | 5 +- plugins/modules/oci_file_storage_snapshot.py | 29 +- .../oci_file_storage_snapshot_facts.py | 5 +- plugins/modules/oci_functions_application.py | 393 +++++++ .../oci_functions_application_facts.py | 305 +++++ plugins/modules/oci_functions_function.py | 453 ++++++++ .../modules/oci_functions_function_actions.py | 316 ++++++ .../modules/oci_functions_function_facts.py | 343 ++++++ ...hecks_health_checks_vantage_point_facts.py | 5 +- .../modules/oci_healthchecks_http_monitor.py | 32 +- .../oci_healthchecks_http_monitor_facts.py | 5 +- .../modules/oci_healthchecks_http_probe.py | 14 +- ...ci_healthchecks_http_probe_result_facts.py | 5 +- .../modules/oci_healthchecks_ping_monitor.py | 32 +- .../oci_healthchecks_ping_monitor_facts.py | 5 +- .../modules/oci_healthchecks_ping_probe.py | 14 +- ...ci_healthchecks_ping_probe_result_facts.py | 5 +- plugins/modules/oci_identity_api_key.py | 29 +- plugins/modules/oci_identity_api_key_facts.py | 5 +- plugins/modules/oci_identity_auth_token.py | 29 +- .../modules/oci_identity_auth_token_facts.py | 5 +- .../oci_identity_authentication_policy.py | 7 +- ...ci_identity_authentication_policy_facts.py | 5 +- .../oci_identity_availability_domain_facts.py | 5 +- plugins/modules/oci_identity_compartment.py | 29 +- .../modules/oci_identity_compartment_facts.py | 5 +- .../oci_identity_cost_tracking_tag_facts.py | 5 +- .../oci_identity_customer_secret_key.py | 29 +- .../oci_identity_customer_secret_key_facts.py | 5 +- plugins/modules/oci_identity_dynamic_group.py | 29 +- .../oci_identity_dynamic_group_facts.py | 5 +- .../oci_identity_fault_domain_facts.py | 5 +- plugins/modules/oci_identity_group.py | 29 +- plugins/modules/oci_identity_group_facts.py | 5 +- .../modules/oci_identity_idp_group_mapping.py | 29 +- .../oci_identity_idp_group_mapping_facts.py | 5 +- .../modules/oci_identity_mfa_totp_device.py | 29 +- .../oci_identity_mfa_totp_device_actions.py | 9 +- .../oci_identity_mfa_totp_device_facts.py | 5 +- plugins/modules/oci_identity_policy.py | 29 +- plugins/modules/oci_identity_policy_facts.py | 5 +- plugins/modules/oci_identity_provider.py | 29 +- .../modules/oci_identity_provider_actions.py | 8 +- .../modules/oci_identity_provider_facts.py | 5 +- .../oci_identity_provider_group_facts.py | 5 +- plugins/modules/oci_identity_region_facts.py | 5 +- .../oci_identity_region_subscription_facts.py | 5 +- .../modules/oci_identity_smtp_credential.py | 29 +- .../oci_identity_smtp_credential_facts.py | 5 +- plugins/modules/oci_identity_tag.py | 29 +- plugins/modules/oci_identity_tag_default.py | 35 +- .../modules/oci_identity_tag_default_facts.py | 5 +- plugins/modules/oci_identity_tag_facts.py | 5 +- plugins/modules/oci_identity_tag_namespace.py | 29 +- .../oci_identity_tag_namespace_facts.py | 5 +- plugins/modules/oci_identity_tenancy_facts.py | 5 +- plugins/modules/oci_identity_ui_password.py | 14 +- plugins/modules/oci_identity_user.py | 29 +- plugins/modules/oci_identity_user_facts.py | 5 +- .../oci_identity_user_group_membership.py | 33 +- ...ci_identity_user_group_membership_facts.py | 5 +- .../oci_key_management_decrypted_data.py | 14 +- .../oci_key_management_encrypted_data.py | 14 +- .../oci_key_management_generated_key.py | 14 +- plugins/modules/oci_key_management_key.py | 29 +- .../modules/oci_key_management_key_actions.py | 11 +- .../modules/oci_key_management_key_facts.py | 5 +- .../modules/oci_key_management_key_version.py | 29 +- .../oci_key_management_key_version_actions.py | 9 +- .../oci_key_management_key_version_facts.py | 5 +- plugins/modules/oci_key_management_vault.py | 29 +- .../oci_key_management_vault_actions.py | 9 +- .../modules/oci_key_management_vault_facts.py | 5 +- plugins/modules/oci_loadbalancer_backend.py | 29 +- .../modules/oci_loadbalancer_backend_facts.py | 5 +- .../oci_loadbalancer_backend_health_facts.py | 5 +- .../modules/oci_loadbalancer_backend_set.py | 29 +- .../oci_loadbalancer_backend_set_facts.py | 5 +- ...i_loadbalancer_backend_set_health_facts.py | 5 +- .../modules/oci_loadbalancer_certificate.py | 29 +- .../oci_loadbalancer_certificate_facts.py | 5 +- .../oci_loadbalancer_health_checker.py | 7 +- .../oci_loadbalancer_health_checker_facts.py | 5 +- .../modules/oci_loadbalancer_health_facts.py | 5 +- plugins/modules/oci_loadbalancer_hostname.py | 29 +- .../oci_loadbalancer_hostname_facts.py | 5 +- plugins/modules/oci_loadbalancer_listener.py | 7 +- .../modules/oci_loadbalancer_load_balancer.py | 32 +- .../oci_loadbalancer_load_balancer_facts.py | 5 +- .../oci_loadbalancer_path_route_set.py | 29 +- .../oci_loadbalancer_path_route_set_facts.py | 5 +- .../modules/oci_loadbalancer_policy_facts.py | 5 +- .../oci_loadbalancer_protocol_facts.py | 5 +- plugins/modules/oci_loadbalancer_rule_set.py | 29 +- .../oci_loadbalancer_rule_set_facts.py | 5 +- .../modules/oci_loadbalancer_shape_facts.py | 5 +- .../oci_marketplace_accepted_agreement.py | 394 +++++++ ...ci_marketplace_accepted_agreement_facts.py | 269 +++++ .../oci_marketplace_agreement_facts.py | 230 ++++ .../modules/oci_marketplace_category_facts.py | 135 +++ .../modules/oci_marketplace_listing_facts.py | 793 +++++++++++++ .../oci_marketplace_listing_package_facts.py | 427 +++++++ .../oci_marketplace_publisher_facts.py | 159 +++ plugins/modules/oci_monitoring_alarm.py | 680 +++++++++++ plugins/modules/oci_monitoring_alarm_facts.py | 449 ++++++++ ...nitoring_alarm_history_collection_facts.py | 220 ++++ .../oci_monitoring_alarm_status_facts.py | 255 +++++ .../modules/oci_monitoring_metric_actions.py | 290 +++++ plugins/modules/oci_monitoring_metric_data.py | 408 +++++++ .../oci_monitoring_metric_data_actions.py | 322 ++++++ .../oci_monitoring_suppression_actions.py | 154 +++ plugins/modules/oci_network_cpe.py | 62 +- .../oci_network_cpe_config_content_facts.py | 139 +++ .../oci_network_cpe_device_shape_facts.py | 160 +++ plugins/modules/oci_network_cpe_facts.py | 23 +- plugins/modules/oci_network_cross_connect.py | 33 +- .../oci_network_cross_connect_facts.py | 5 +- .../oci_network_cross_connect_group.py | 32 +- .../oci_network_cross_connect_group_facts.py | 5 +- ...ci_network_cross_connect_location_facts.py | 5 +- ...rk_cross_connect_port_speed_shape_facts.py | 5 +- .../oci_network_cross_connect_status_facts.py | 5 +- plugins/modules/oci_network_dhcp_options.py | 32 +- .../modules/oci_network_dhcp_options_facts.py | 5 +- plugins/modules/oci_network_drg.py | 29 +- plugins/modules/oci_network_drg_attachment.py | 44 +- .../oci_network_drg_attachment_facts.py | 11 +- plugins/modules/oci_network_drg_facts.py | 5 +- ...ork_fast_connect_provider_service_facts.py | 5 +- ...fast_connect_provider_service_key_facts.py | 5 +- ...e_virtual_circuit_bandwidth_shape_facts.py | 5 +- .../modules/oci_network_internet_gateway.py | 32 +- .../oci_network_internet_gateway_facts.py | 5 +- .../modules/oci_network_ip_sec_connection.py | 91 +- ...sec_connection_cpe_config_content_facts.py | 142 +++ ...k_ip_sec_connection_device_config_facts.py | 5 +- ...k_ip_sec_connection_device_status_facts.py | 5 +- .../oci_network_ip_sec_connection_facts.py | 28 +- .../oci_network_ip_sec_connection_tunnel.py | 45 +- ...sec_connection_tunnel_cpe_device_config.py | 216 ++++ ..._tunnel_cpe_device_config_content_facts.py | 156 +++ ...nnection_tunnel_cpe_device_config_facts.py | 168 +++ ..._network_ip_sec_connection_tunnel_facts.py | 12 +- ..._ip_sec_connection_tunnel_shared_secret.py | 7 +- ...c_connection_tunnel_shared_secret_facts.py | 5 +- .../oci_network_letter_of_authority_facts.py | 5 +- .../oci_network_local_peering_gateway.py | 33 +- ...i_network_local_peering_gateway_actions.py | 10 +- ...oci_network_local_peering_gateway_facts.py | 7 +- plugins/modules/oci_network_nat_gateway.py | 33 +- .../modules/oci_network_nat_gateway_facts.py | 5 +- ...rk_peer_region_for_remote_peering_facts.py | 5 +- plugins/modules/oci_network_private_ip.py | 37 +- .../modules/oci_network_private_ip_facts.py | 5 +- plugins/modules/oci_network_public_ip.py | 32 +- .../modules/oci_network_public_ip_facts.py | 5 +- .../oci_network_remote_peering_connection.py | 32 +- ...twork_remote_peering_connection_actions.py | 8 +- ...network_remote_peering_connection_facts.py | 5 +- plugins/modules/oci_network_route_table.py | 32 +- .../modules/oci_network_route_table_facts.py | 5 +- plugins/modules/oci_network_security_group.py | 33 +- .../oci_network_security_group_facts.py | 5 +- ...rk_security_group_security_rule_actions.py | 10 +- ...work_security_group_security_rule_facts.py | 5 +- .../oci_network_security_group_vnic_facts.py | 5 +- plugins/modules/oci_network_security_list.py | 32 +- .../oci_network_security_list_facts.py | 5 +- plugins/modules/oci_network_service_facts.py | 5 +- .../modules/oci_network_service_gateway.py | 52 +- .../oci_network_service_gateway_actions.py | 18 +- .../oci_network_service_gateway_facts.py | 14 +- plugins/modules/oci_network_subnet.py | 32 +- plugins/modules/oci_network_subnet_facts.py | 5 +- plugins/modules/oci_network_vcn.py | 32 +- plugins/modules/oci_network_vcn_facts.py | 5 +- .../modules/oci_network_virtual_circuit.py | 54 +- .../oci_network_virtual_circuit_actions.py | 20 +- ...k_virtual_circuit_bandwidth_shape_facts.py | 5 +- .../oci_network_virtual_circuit_facts.py | 16 +- ...ork_virtual_circuit_public_prefix_facts.py | 5 +- plugins/modules/oci_network_vnic.py | 7 +- plugins/modules/oci_network_vnic_facts.py | 5 +- plugins/modules/oci_object_storage_bucket.py | 29 +- .../oci_object_storage_bucket_actions.py | 9 +- .../oci_object_storage_bucket_facts.py | 5 +- .../oci_object_storage_namespace_facts.py | 5 +- .../oci_object_storage_namespace_metadata.py | 7 +- ...object_storage_namespace_metadata_facts.py | 5 +- plugins/modules/oci_object_storage_object.py | 29 +- .../oci_object_storage_object_actions.py | 10 +- .../oci_object_storage_object_facts.py | 5 +- ..._object_storage_object_lifecycle_policy.py | 7 +- ...t_storage_object_lifecycle_policy_facts.py | 5 +- ...oci_object_storage_object_version_facts.py | 5 +- ...object_storage_preauthenticated_request.py | 29 +- ..._storage_preauthenticated_request_facts.py | 5 +- .../oci_object_storage_replication_policy.py | 29 +- ...object_storage_replication_policy_facts.py | 5 +- ...object_storage_replication_source_facts.py | 5 +- .../oci_object_storage_retention_rule.py | 29 +- ...oci_object_storage_retention_rule_facts.py | 5 +- plugins/modules/oci_ons_notification_topic.py | 372 ++++++ .../oci_ons_notification_topic_facts.py | 273 +++++ plugins/modules/oci_ons_subscription.py | 428 +++++++ .../modules/oci_ons_subscription_actions.py | 300 +++++ ...oci_ons_subscription_confirmation_facts.py | 201 ++++ plugins/modules/oci_ons_subscription_facts.py | 280 +++++ .../oci_secrets_secret_bundle_facts.py | 5 +- ...oci_secrets_secret_bundle_version_facts.py | 5 +- .../modules/oci_streaming_connect_harness.py | 356 ++++++ .../oci_streaming_connect_harness_facts.py | 276 +++++ plugins/modules/oci_streaming_stream.py | 395 +++++++ plugins/modules/oci_streaming_stream_facts.py | 308 +++++ plugins/modules/oci_streaming_stream_pool.py | 538 +++++++++ .../oci_streaming_stream_pool_facts.py | 381 +++++++ plugins/modules/oci_vault_secret.py | 32 +- plugins/modules/oci_vault_secret_actions.py | 9 +- plugins/modules/oci_vault_secret_facts.py | 5 +- .../oci_vault_secret_version_actions.py | 9 +- .../modules/oci_vault_secret_version_facts.py | 5 +- .../database/autonomous_database/sample.yaml | 18 +- .../autonomous_database/teardown.yaml | 6 + 395 files changed, 24137 insertions(+), 2823 deletions(-) create mode 100644 plugins/module_utils/oci_custom_helpers_utils.py create mode 100644 plugins/module_utils/oci_dns_custom_helpers.py create mode 100644 plugins/module_utils/oci_functions_custom_helpers.py rename plugins/module_utils/{oci_healthchecks_custom_helpers.py => oci_marketplace_custom_helpers.py} (52%) create mode 100644 plugins/module_utils/oci_monitoring_custom_helpers.py create mode 100644 plugins/module_utils/oci_ons_custom_helpers.py create mode 100644 plugins/module_utils/oci_streaming_custom_helpers.py create mode 100644 plugins/modules/oci_compute_dedicated_vm_host_instance_shape_facts.py create mode 100644 plugins/modules/oci_compute_dedicated_vm_host_shape_facts.py create mode 100644 plugins/modules/oci_compute_image_shape_compatibility_entry_facts.py create mode 100644 plugins/modules/oci_database_data_guard_association.py create mode 100644 plugins/modules/oci_database_data_guard_association_actions.py create mode 100644 plugins/modules/oci_database_data_guard_association_facts.py create mode 100644 plugins/modules/oci_dns_domain_records.py create mode 100644 plugins/modules/oci_dns_domain_records_facts.py create mode 100644 plugins/modules/oci_dns_rrset.py create mode 100644 plugins/modules/oci_dns_rrset_facts.py create mode 100644 plugins/modules/oci_dns_steering_policy.py create mode 100644 plugins/modules/oci_dns_steering_policy_attachment.py create mode 100644 plugins/modules/oci_dns_steering_policy_attachment_facts.py create mode 100644 plugins/modules/oci_dns_steering_policy_facts.py create mode 100644 plugins/modules/oci_dns_tsig_key.py create mode 100644 plugins/modules/oci_dns_tsig_key_facts.py create mode 100644 plugins/modules/oci_dns_zone.py create mode 100644 plugins/modules/oci_dns_zone_facts.py create mode 100644 plugins/modules/oci_dns_zone_records.py create mode 100644 plugins/modules/oci_dns_zone_records_facts.py create mode 100644 plugins/modules/oci_email_sender.py create mode 100644 plugins/modules/oci_email_sender_facts.py create mode 100644 plugins/modules/oci_email_suppression.py create mode 100644 plugins/modules/oci_email_suppression_facts.py create mode 100644 plugins/modules/oci_functions_application.py create mode 100644 plugins/modules/oci_functions_application_facts.py create mode 100644 plugins/modules/oci_functions_function.py create mode 100644 plugins/modules/oci_functions_function_actions.py create mode 100644 plugins/modules/oci_functions_function_facts.py create mode 100644 plugins/modules/oci_marketplace_accepted_agreement.py create mode 100644 plugins/modules/oci_marketplace_accepted_agreement_facts.py create mode 100644 plugins/modules/oci_marketplace_agreement_facts.py create mode 100644 plugins/modules/oci_marketplace_category_facts.py create mode 100644 plugins/modules/oci_marketplace_listing_facts.py create mode 100644 plugins/modules/oci_marketplace_listing_package_facts.py create mode 100644 plugins/modules/oci_marketplace_publisher_facts.py create mode 100644 plugins/modules/oci_monitoring_alarm.py create mode 100644 plugins/modules/oci_monitoring_alarm_facts.py create mode 100644 plugins/modules/oci_monitoring_alarm_history_collection_facts.py create mode 100644 plugins/modules/oci_monitoring_alarm_status_facts.py create mode 100644 plugins/modules/oci_monitoring_metric_actions.py create mode 100644 plugins/modules/oci_monitoring_metric_data.py create mode 100644 plugins/modules/oci_monitoring_metric_data_actions.py create mode 100644 plugins/modules/oci_monitoring_suppression_actions.py create mode 100644 plugins/modules/oci_network_cpe_config_content_facts.py create mode 100644 plugins/modules/oci_network_cpe_device_shape_facts.py create mode 100644 plugins/modules/oci_network_ip_sec_connection_cpe_config_content_facts.py create mode 100644 plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config.py create mode 100644 plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_content_facts.py create mode 100644 plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_facts.py create mode 100644 plugins/modules/oci_ons_notification_topic.py create mode 100644 plugins/modules/oci_ons_notification_topic_facts.py create mode 100644 plugins/modules/oci_ons_subscription.py create mode 100644 plugins/modules/oci_ons_subscription_actions.py create mode 100644 plugins/modules/oci_ons_subscription_confirmation_facts.py create mode 100644 plugins/modules/oci_ons_subscription_facts.py create mode 100644 plugins/modules/oci_streaming_connect_harness.py create mode 100644 plugins/modules/oci_streaming_connect_harness_facts.py create mode 100644 plugins/modules/oci_streaming_stream.py create mode 100644 plugins/modules/oci_streaming_stream_facts.py create mode 100644 plugins/modules/oci_streaming_stream_pool.py create mode 100644 plugins/modules/oci_streaming_stream_pool_facts.py diff --git a/CHANGELOG.md b/CHANGELOG.md index e501960878..7a9b4e1f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.2.0] - 2020-6-25 + +### Added: +- Added Domain Name System (DNS) modules +- Added Email modules +- Added Marketplace modules +- Added Monitoring modules +- Added Notifications modules +- Added Streaming modules +- Added Functions modules +- Added Database Data Guard modules +- Added new modules for Compute and Network +- Added subparameter `admission_controller_options` in the options parameter of module `oci_container_engine_cluster` +- Added `node_source_details` parameter in the `oci_container_engine_node_pool module` + +### Changed: +- Please update to the latest version of OCI Python SDK. +- `compartment_id` parameter removed from `oci_database_maintenance_run.py` + - This parameter was optional and was unused by the module so is being removed + ## [2.1.2-Beta] - 2020-6-9 ### Changed: diff --git a/MigrationGuide.md b/MigrationGuide.md index fb800d92f7..200bd16df1 100644 --- a/MigrationGuide.md +++ b/MigrationGuide.md @@ -155,6 +155,8 @@ No breaking changes |oci_database_facts | oci_database_database_facts | Module name is the only breaking change |oci_backup | oci_database_backup | Breaking changes: |oci_backup_facts | oci_database_backup_facts | Breaking changes: +|oci_data_guard_association | oci_database_data_guard_association | Breaking changes: +|oci_data_guard_association_facts | oci_database_data_guard_association_facts | Module name is the only breaking change |oci_db_home | oci_database_db_home | Breaking changes: |oci_db_home_facts | oci_database_db_home_facts | Module name is the only breaking change |oci_db_home_patch_facts | oci_database_db_home_patch_facts | Module name is the only breaking change @@ -184,6 +186,15 @@ No breaking changes |oci_autonomous_exadata_infrastructure_facts | oci_database_autonomous_exadata_infrastructure_facts | Breaking changes due to service API change: |oci_autonomous_exadata_infrastructure_shape_facts | oci_database_autonomous_exadata_infrastructure_shape_facts | Module name is the only breaking change +#### Email + +|old name | new name | migration notes +|-----------------------|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +|oci_sender | oci_email_sender | Module name is the only breaking change +|oci_sender_facts | oci_email_sender_facts | Module name is the only breaking change +|oci_suppression | oci_email_suppression | Module name is the only breaking change +|oci_suppression_facts | oci_email_suppression_facts | Module name is the only breaking change + #### File Storage |old name | new name | migration notes @@ -343,3 +354,16 @@ No breaking changes |oci_object_storage_object_lifecycle_policy_facts | oci_object_storage_object_lifecycle_policy_facts | Module name is the only breaking change |oci_preauthenticated_request | oci_object_storage_preauthenticated_request | Breaking changes: |oci_preauthenticated_request_facts | oci_object_storage_preauthenticated_request_facts | Module name is the only breaking change + +#### DNS + +|old name | new name | migration notes +|-------------------------------------------------|-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------- +|oci_zone | oci_dns_zone | Breaking changes: +|oci_zone_facts | oci_dns_zone_facts | Module name is the only breaking change +|oci_zone_records | oci_dns_zone_records | Module name is the only breaking change +|oci_zone_records_facts | oci_dns_zone_records_facts | Module name is the only breaking change +|oci_domain_records | oci_dns_domain_records | Module name is the only breaking change +|oci_domain_records_facts | oci_dns_domain_records_facts | Module name is the only breaking change +|oci_rrset | oci_dns_rrset | Module name is the only breaking change +|oci_rrset_facts | oci_dns_rrset_facts | Module name is the only breaking change diff --git a/README.md b/README.md index 47da97465d..64c1b59c28 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ -# Oracle Cloud Infrastructure Ansible Collection - Beta -While we are in beta, you **must** specify the version while installing oracle.oci `ansible-galaxy collection install oracle.oci:`. To install the latest version (2.1.2-beta), use the following command: -> **ansible-galaxy collection install oracle.oci:2.1.2-beta** - +# Oracle Cloud Infrastructure Ansible Collection Oracle Cloud Infrastructure Ansible Collection provides an easy way to provision and manage resources in Oracle Cloud using Ansible. @@ -38,6 +35,13 @@ We have also added a new [User Guide](https://github.com/oracle/oci-ansible-coll - Budget/Account management - Health Checks - Vault Secret and Key Management (KMS) +- Domain Name System (DNS) +- Email +- Marketplace +- Monitoring +- Notifications +- Streaming +- Functions ## Installation @@ -46,7 +50,7 @@ We have also added a new [User Guide](https://github.com/oracle/oci-ansible-coll You can install it from [Ansible Galaxy](https://galaxy.ansible.com/oracle) using the command: ``` bash - $ ansible-galaxy collection install oracle.oci:2.1.2-beta + $ ansible-galaxy collection install oracle.oci ``` Notes: * Collections is supported in Ansible 2.9+. diff --git a/UserGuide.md b/UserGuide.md index a3ef74f58a..f371fca27f 100644 --- a/UserGuide.md +++ b/UserGuide.md @@ -61,4 +61,7 @@ There would be no ambiguity and it would only ever match the 50 GB block volume. It is important to note that matching these extra fields only comes into play if *all* other fields match *and* you did not specify optional values with defaults. Thus, this corner case can be avoided very easily by doing either of the following: - Use unique attributes or tags for resources of the same type so there is no potential for ambiguity in matching resources -- Specify optional values that you care about instead of relying on server side defaults \ No newline at end of file +- Specify optional values that you care about instead of relying on server side defaults + +### Support for `key_by` option +All modules support the key_by option. It takes a list of comma-separated attributes of the resource which should be used to uniquely identify the resource. By default, all the attributes of a resource are used to uniquely identify a resource. \ No newline at end of file diff --git a/galaxy.yml b/galaxy.yml index 999fa832a5..f2201f180a 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: oracle name: oci # The version of the collection. Must be compatible with semantic versioning -version: 2.1.2-beta +version: 2.2.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/plugins/doc_fragments/oracle_creatable_resource.py b/plugins/doc_fragments/oracle_creatable_resource.py index 4eeaa0551d..8fd49f4ef3 100644 --- a/plugins/doc_fragments/oracle_creatable_resource.py +++ b/plugins/doc_fragments/oracle_creatable_resource.py @@ -21,7 +21,7 @@ class ModuleDocFragment(object): type: bool key_by: description: The list of comma-separated attributes of this resource which should be used to uniquely - identify an instance of the resource. By default, all the attributes of a resource except - I(freeform_tags) are used to uniquely identify a resource. + identify an instance of the resource. By default, all the attributes of a resource are + used to uniquely identify a resource. type: list """ diff --git a/plugins/module_utils/oci_common_utils.py b/plugins/module_utils/oci_common_utils.py index 5b07a11883..33c0e93c61 100644 --- a/plugins/module_utils/oci_common_utils.py +++ b/plugins/module_utils/oci_common_utils.py @@ -54,10 +54,11 @@ ] CANCELLED_STATES = ["CANCELLED"] +FAILED_STATES = ["FAILED"] WORK_REQUEST_COMPLETED_STATES = ["SUCCEEDED", "SUCCESS", "FAILED", "COMPLETED"] WORK_REQUEST_SUCCESS_STATES = ["SUCCEEDED", "SUCCESS"] -WORK_REQUEST_FAILED_STATES = ["FAILED"] +WORK_REQUEST_FAILED_STATES = FAILED_STATES # If a resource is in one of these states, it would be considered deleted DEFAULT_TERMINATED_STATES = ["TERMINATED", "DETACHED", "DELETED"] @@ -96,6 +97,7 @@ CREATE_OPERATION_KEY = "CREATE" UPDATE_OPERATION_KEY = "UPDATE" +PATCH_OPERATION_KEY = "PATCH" DELETE_OPERATION_KEY = "DELETE" ACTION_OPERATION_KEY = "ACTION" ANY_OPERATION_KEY = "ANY" @@ -199,7 +201,7 @@ def list_all_resources(target_fn, **kwargs): # compare_dicts is used to compare create and update model dicts with the existing resource. Since the existing # resource might have more parameters (for ex: OCID, time_created etc) than the information we provide during the # creation, we do a subset match of the dictionary. -# But if a parameter present in create/update model and not in existing resource, it is considered a mismatch by default +# But if a parameter present in the create/update model and not in existing resource, it is considered a mismatch by default # This behaviour can be changed by setting the flag `ignore_attr_if_not_in_target`. def compare_dicts( source_dict, target_dict, attrs=None, ignore_attr_if_not_in_target=False @@ -284,7 +286,7 @@ def compare_dicts( return True -def compare_lists(source_list, target_list): +def compare_lists(source_list, target_list, ignore_attr_if_not_in_target=False): if source_list is None or target_list is None: _debug( "list is not subset because source list: {source_list} or target list: {target_list} is None".format( @@ -308,7 +310,16 @@ def compare_lists(source_list, target_list): ) return False - if all([is_in_list(target_list, element) for element in source_list]): + if all( + [ + is_in_list( + target_list, + element, + ignore_attr_if_not_in_target=ignore_attr_if_not_in_target, + ) + for element in source_list + ] + ): return True _debug( @@ -317,15 +328,29 @@ def compare_lists(source_list, target_list): return False -def is_in_list(target_list, element): +def is_in_list(target_list, element, ignore_attr_if_not_in_target=False): if isinstance(element, dict): if any( - [compare_dicts(element, target_element) for target_element in target_list] + [ + compare_dicts( + element, + target_element, + ignore_attr_if_not_in_target=ignore_attr_if_not_in_target, + ) + for target_element in target_list + ] ): return True elif isinstance(element, list): if any( - [compare_lists(element, target_element) for target_element in target_list] + [ + compare_lists( + element, + target_element, + ignore_attr_if_not_in_target=ignore_attr_if_not_in_target, + ) + for target_element in target_list + ] ): return True else: diff --git a/plugins/module_utils/oci_compute_custom_helpers.py b/plugins/module_utils/oci_compute_custom_helpers.py index 84b0b40c61..8658815c32 100644 --- a/plugins/module_utils/oci_compute_custom_helpers.py +++ b/plugins/module_utils/oci_compute_custom_helpers.py @@ -17,7 +17,6 @@ try: from oci.core import VirtualNetworkClient from oci.util import to_dict - from oci.core.models import ImageShapeCompatibilityEntry from oci.exceptions import ServiceError HAS_OCI_PY_SDK = True @@ -249,23 +248,31 @@ def get_exclude_attributes(self): class ImageShapeCompatibilityEntryHelperCustom: - def get_resource(self): - # This resource does not have a get or list method. `update` and `delete` does not return anything and - # updating even if the entry exists does not throw any error. Same with delete. So choosing to make the API - # call always. The customisation for `get_resource` is only to make the other functions work and to return - # some data to the user. - return oci_common_utils.get_default_response_from_resource( - resource=oci_common_utils.convert_input_data_to_model_class( - self.module.params, ImageShapeCompatibilityEntry - ) - ) + def is_update(self): + if not self.module.params.get("state") == "present": + return False - def is_update_necessary(self): - # This resource does not have a get or list method. So no way to check if it already exists or not. So always - # update. Also making the API call even if the entry exists does not throw any error. So choosing to make - # the API call always. return True + def get_existing_resource_dict_for_update(self): + try: + get_response = self.get_resource() + except ServiceError as se: + if se.status != 404: + raise + return dict() + else: + return to_dict(get_response.data) + + def is_update_necessary(self, existing_resource_dict): + + if not existing_resource_dict: + return True + + return super( + ImageShapeCompatibilityEntryHelperCustom, self + ).is_update_necessary(existing_resource_dict) + class VnicAttachmentHelperCustom: def get_create_model_dict_for_idempotence_check(self, create_model): diff --git a/plugins/module_utils/oci_compute_management_custom_helpers.py b/plugins/module_utils/oci_compute_management_custom_helpers.py index 0cb7d80605..76716fd6bf 100644 --- a/plugins/module_utils/oci_compute_management_custom_helpers.py +++ b/plugins/module_utils/oci_compute_management_custom_helpers.py @@ -46,17 +46,6 @@ def __init__(self, *args, **kwargs): self.module, BlockstorageClient ) - def list_resources(self): - # list only returns summary objects which have very little information. This causes false positives since we - # compare only a handful of basic parameters. So do a get call and get the full - # model objects for idempotence check. - return [ - self.get_get_fn()(instance_configuration_id=instance_configuration.id).data - for instance_configuration in super( - InstanceConfigurationHelperCustom, self - ).list_resources() - ] - def get_instance_configuration_launch_details_from_instance(self, instance): launch_details = oci_common_utils.convert_input_data_to_model_class( to_dict(instance), InstanceConfigurationLaunchInstanceDetails @@ -148,21 +137,6 @@ def get_create_model_dict_for_idempotence_check(self, create_model): class InstanceConfigurationActionsHelperCustom: - # Launch method creates an instance but the generated method does not wait until the instance is in running state. - # Override and wait until the instance reaches the ready state. - # def launch(self): - # instance = super(InstanceConfigurationActionsHelperCustom, self).launch() - # compute_client = oci_config_utils.create_service_client( - # self.module, ComputeClient - # ) - # wait_response = oci.wait_until( - # self.client, - # compute_client.get_instance(instance_id=instance.id), - # evaluate_response=lambda response: response.data.lifecycle_state - # in oci_common_utils.DEFAULT_READY_STATES, - # max_wait_seconds=self.get_wait_timeout(), - # ) - # return wait_response.data # instance_configuration launch action returns an instance and not instance_configuration. Currently the base # classes do not support custom return field names and use the resource types. Until the feature is added @@ -176,16 +150,6 @@ def prepare_result(self, *args, **kwargs): return super_result -class InstancePoolHelperCustom: - def list_resources(self): - # list only returns summary objects which does not have all the information in the create model. This causes - # false positives. So do a get call and get the full model objects for idempotence check. - return [ - self.get_get_fn()(instance_pool_id=instance_pool.id).data - for instance_pool in super(InstancePoolHelperCustom, self).list_resources() - ] - - class InstancePoolActionsHelperCustom: LIFECYCLE_STATE_ATTACHED = "ATTACHED" LIFECYCLE_STATE_DETACHED = "DETACHED" diff --git a/plugins/module_utils/oci_container_engine_custom_helpers.py b/plugins/module_utils/oci_container_engine_custom_helpers.py index 16b03b8892..27951b6682 100644 --- a/plugins/module_utils/oci_container_engine_custom_helpers.py +++ b/plugins/module_utils/oci_container_engine_custom_helpers.py @@ -12,12 +12,29 @@ class KubeconfigHelperCustom: - def get_module_resource_id(self): - return False - - def get_matching_resource(self): - return None - def create_resource(self): response_data = super(KubeconfigHelperCustom, self).create_resource() return to_text(response_data.content) + + +class NodePoolHelperCustom: + # Some attrs end with details and the get returns the same field without details + # This case we should still match them for update and create + def get_existing_resource_dict_for_idempotence_check(self, existing_resource): + existing_resource_dict = super( + NodePoolHelperCustom, self + ).get_existing_resource_dict_for_idempotence_check(existing_resource) + if existing_resource_dict.get("node_source"): + existing_resource_dict["node_source_details"] = existing_resource_dict.pop( + "node_source" + ) + return existing_resource_dict + + def is_update_necessary(self, existing_resource_dict): + if existing_resource_dict.get("node_source"): + existing_resource_dict["node_source_details"] = existing_resource_dict.get( + "node_source" + ) + return super(NodePoolHelperCustom, self).is_update_necessary( + existing_resource_dict + ) diff --git a/plugins/module_utils/oci_custom_helpers_utils.py b/plugins/module_utils/oci_custom_helpers_utils.py new file mode 100644 index 0000000000..b13ad8b83e --- /dev/null +++ b/plugins/module_utils/oci_custom_helpers_utils.py @@ -0,0 +1,74 @@ +# Copyright (c) 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import inspect + + +def get_custom_class_mapping(modules): + """Find the custom classes in the given modules and return a mapping with class name as key and class as value""" + custom_class_mapping = {} + for module in modules: + for obj_name in dir(module): + if not obj_name.endswith("Custom"): + continue + obj = getattr(module, obj_name) + if inspect.isclass(obj): + custom_class_mapping[obj_name] = obj + return custom_class_mapping + + +# Due to the generalisations made about the resource APIs or because of the ease of use enhancements, the generated +# modules might not always be perfect. The custom behaviour is handled by having a custom class which is used to +# override the generated behaviour. Create a mapping of those custom classes so that we can dynamically override +# the behaviour. +# import the customisation files. +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_identity_custom_helpers, + oci_network_custom_helpers, + oci_compute_custom_helpers, + oci_blockstorage_custom_helpers, + oci_compute_management_custom_helpers, + oci_audit_custom_helpers, + oci_object_storage_custom_helpers, + oci_key_management_custom_helpers, + oci_file_storage_custom_helpers, + oci_container_engine_custom_helpers, + oci_load_balancer_custom_helpers, + oci_database_custom_helpers, + oci_streaming_custom_helpers, + oci_functions_custom_helpers, + oci_marketplace_custom_helpers, + oci_dns_custom_helpers, + oci_monitoring_custom_helpers, + oci_ons_custom_helpers, +) # noqa + +custom_helper_mapping = get_custom_class_mapping( + [ + oci_identity_custom_helpers, + oci_network_custom_helpers, + oci_compute_custom_helpers, + oci_blockstorage_custom_helpers, + oci_compute_management_custom_helpers, + oci_audit_custom_helpers, + oci_object_storage_custom_helpers, + oci_key_management_custom_helpers, + oci_file_storage_custom_helpers, + oci_container_engine_custom_helpers, + oci_load_balancer_custom_helpers, + oci_database_custom_helpers, + oci_streaming_custom_helpers, + oci_functions_custom_helpers, + oci_marketplace_custom_helpers, + oci_dns_custom_helpers, + oci_monitoring_custom_helpers, + oci_ons_custom_helpers, + ] +) diff --git a/plugins/module_utils/oci_database_custom_helpers.py b/plugins/module_utils/oci_database_custom_helpers.py index 45913a8662..5e4d10b262 100644 --- a/plugins/module_utils/oci_database_custom_helpers.py +++ b/plugins/module_utils/oci_database_custom_helpers.py @@ -163,16 +163,17 @@ def get_exclude_attributes(self): "db_home", ] - def is_update_necessary(self): - needs_update = super(DbSystemHelperCustom, self).is_update_necessary() + def is_update_necessary(self, existing_resource_dict): + needs_update = super(DbSystemHelperCustom, self).is_update_necessary( + existing_resource_dict + ) if not needs_update: - current_resource = self.get_resource().data update_model = self.get_update_model() needs_update = is_patch_necessary( patch_getter_method=self.client.get_db_system_patch, - current_version=current_resource.version, + current_version=existing_resource_dict.get("version"), requested_patch_details=update_model.version, - db_system_id=current_resource.id, + db_system_id=existing_resource_dict.get("id"), ) return needs_update @@ -222,20 +223,72 @@ def get_update_model_dict_for_idempotence_check(self, update_model): return update_model_dict - def is_update_necessary(self): + def is_update_necessary(self, resource=None): # dbVersion is the only updatable field so it is the only thing we need to check to determine # if an update is necessary - current_resource = self.get_resource().data update_model = self.get_update_model() needs_update = is_patch_necessary( patch_getter_method=self.client.get_db_home_patch, - current_version=current_resource.db_version, + current_version=resource["db_version"], requested_patch_details=update_model.db_version, - db_home_id=current_resource.id, + db_home_id=resource["id"], ) return needs_update +class DataGuardAssociationHelperCustom: + def get_module_resource_id(self): + return None + + def get_module_resource_id_param(self): + return None + + def get_get_model_from_summary_model(self, summary_model): + return self.client.get_data_guard_association( + database_id=self.module.params["database_id"], + data_guard_association_id=summary_model.id, + ).data + + def get_get_fn(self): + def get_fn(data_guard_association_id): + return self.client.get_data_guard_association( + data_guard_association_id=data_guard_association_id, + database_id=self.module.params["database_id"], + ) + + return get_fn + # return self.client.get_data_guard_association + + def get_exclude_attributes(self): + exclude_attributes = super( + DataGuardAssociationHelperCustom, self + ).get_exclude_attributes() + return exclude_attributes + [ + # not returned by GET model + "database_admin_password", + # discriminator, not returned by GET (existing vs new db system) + "creation_type", + ] + + +class DataGuardAssociationActionsHelperCustom: + def is_action_necessary(self, action, resource=None): + data_guard_association = resource or self.get_resource().data + + # This mirrors the old behavior + if action == "switchover" and data_guard_association.role == "PRIMARY": + return True + if action == "failover" and data_guard_association.role == "STANDBY": + return True + if ( + action == "reinstate" + and data_guard_association.peer_role == "DISABLED_STANDBY" + ): + return True + + return False + + def is_patch_necessary( patch_getter_method, current_version, requested_patch_details, **kwargs ): diff --git a/plugins/module_utils/oci_dns_custom_helpers.py b/plugins/module_utils/oci_dns_custom_helpers.py new file mode 100644 index 0000000000..ef1d794bdf --- /dev/null +++ b/plugins/module_utils/oci_dns_custom_helpers.py @@ -0,0 +1,123 @@ +# Copyright (c) 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils + +try: + from oci.util import to_dict + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + +logger = oci_common_utils.get_logger("oci_dns_custom_helpers") + + +def _debug(s): + get_logger().debug(s) + + +def get_logger(): + return logger + + +class ZoneHelperCustom: + def get_create_model_dict_for_idempotence_check(self, create_model): + create_model_dict = super( + ZoneHelperCustom, self + ).get_create_model_dict_for_idempotence_check(create_model) + # migration_source is a discriminator field and dynect_migration_details is not available in the get model + create_model_dict.pop("migration_source", None) + create_model_dict.pop("dynect_migration_details", None) + return create_model_dict + + +# This class handles some of the common customisations across some of the dns modules which works on a collection of +# records. For ex: zone_records, domain_records, rrset etc. +# +# Some of the common customisations that apply to these modules are: +# * Have both update and patch methods and differentiators method customisations (is_update, is_patch). There is no +# clear differentiation between between update and patch in general since they both need a resource id and same +# state value. But in the DNS records modules, we can differentiate them using the existence of some attributes like +# update_items, patch_items etc. +# * update_items and patch_items are mutually exclusive +# * update and patch methods do not support check mode and check changed based on the changed resource value +# after performing the operation. This is done so that some of the fields (for ex: rdata) is normalized in the +# server and would not be same to what are sent during create. We need third party libraries if we need to normalize +# and perform the check which is not an option since this would put a dependency on that for using our modules. +# Another option would be to just exclude those attributes but I don't think it is a good idea either since we +# would not be able to handle updates in those fields. This behaviour is consistent with the legacy modules. +class DNSRecordsHelperCustom: + def __init__(self, *args, **kwargs): + super(DNSRecordsHelperCustom, self).__init__(*args, **kwargs) + if ( + self.module.params.get("update_items") is not None + and self.module.params.get("patch_items") is not None + ): + self.module.fail_json( + msg="update_items and patch_items are mutually exclusive" + ) + self.module.params["items"] = self.module.params.get( + "update_items" + ) or self.module.params.get("patch_items") + + def is_update(self): + is_update = super(DNSRecordsHelperCustom, self).is_update() + if not is_update: + return False + if self.module.params.get("update_items") is None: + return False + return True + + def is_patch(self): + is_patch = super(DNSRecordsHelperCustom, self).is_patch() + if not is_patch: + return False + if self.module.params.get("patch_items") is None: + return False + return True + + def update(self): + existing_zone_records = self.get_resource().data + updated_resource = self.update_resource() + updated_zone_records = self.get_resource().data + changed = not oci_common_utils.compare_lists( + to_dict(updated_zone_records), to_dict(existing_zone_records) + ) + return self.prepare_result( + changed=changed, + resource_type=self.resource_type, + resource=to_dict(updated_resource.items), + ) + + def patch(self): + existing_zone_records = self.get_resource().data + patched_resource = self.patch_resource() + patched_zone_records = self.get_resource().data + changed = not oci_common_utils.compare_lists( + to_dict(patched_zone_records), to_dict(existing_zone_records) + ) + return self.prepare_result( + changed=changed, + resource_type=self.resource_type, + resource=to_dict(patched_resource.items), + ) + + +class ZoneRecordsHelperCustom(DNSRecordsHelperCustom): + pass + + +class DomainRecordsHelperCustom(DNSRecordsHelperCustom): + pass + + +class RrsetHelperCustom(DNSRecordsHelperCustom): + pass diff --git a/plugins/module_utils/oci_file_storage_custom_helpers.py b/plugins/module_utils/oci_file_storage_custom_helpers.py index cad48cf236..76bc9b4540 100644 --- a/plugins/module_utils/oci_file_storage_custom_helpers.py +++ b/plugins/module_utils/oci_file_storage_custom_helpers.py @@ -32,18 +32,6 @@ def list_resources(self): class MountTargetHelperCustom: - def list_resources(self): - existing_mount_targets_summary = to_dict( - super(MountTargetHelperCustom, self).list_resources() - ) - result = [ - oci_common_utils.call_with_backoff( - self.client.get_mount_target, mount_target_id=mount_target["id"], - ).data - for mount_target in existing_mount_targets_summary - ] - return result - def get_exclude_attributes(self): exclude_attributes = super( MountTargetHelperCustom, self @@ -52,17 +40,3 @@ def get_exclude_attributes(self): "hostname_label", "ip_address", ] - - -class ExportHelperCustom: - def list_resources(self): - existing_exports_summary = to_dict( - super(ExportHelperCustom, self).list_resources() - ) - result = [ - oci_common_utils.call_with_backoff( - self.client.get_export, export_id=export["id"] - ).data - for export in existing_exports_summary - ] - return result diff --git a/plugins/module_utils/oci_functions_custom_helpers.py b/plugins/module_utils/oci_functions_custom_helpers.py new file mode 100644 index 0000000000..b3185ff98f --- /dev/null +++ b/plugins/module_utils/oci_functions_custom_helpers.py @@ -0,0 +1,55 @@ +# Copyright (c) 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.oracle.oci.plugins.module_utils import oci_config_utils +from ansible.module_utils._text import to_bytes + +try: + from oci.functions import FunctionsInvokeClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class FunctionActionsHelperCustom: + + # invoke action uses a different client (FunctionsInvokeClient) than the one that is generated for the function + # resource (FunctionsManagementClient) based on other operations. Currently codegen only supports one client class + # for a resource. The other option would have been renaming the resource for this operation which would have + # generated with the invoke client. But we would still need the FunctionsManagementClient to get the functions + # endpoint. + # TODO: Add support for multiple client classes in codegen + def invoke(self): + if not self.module.params.get("dest"): + self.module.fail_json(msg="dest parameter required for invoke action") + dest = self.module.params["dest"] + function = self.get_resource().data + self.module.params["service_endpoint"] = function.invoke_endpoint + functions_invoke_client = oci_config_utils.create_service_client( + self.module, FunctionsInvokeClient + ) + try: + # Temporarily change self.client in the context of this method. Preferring this over overriding the + # self.client to use FunctionsInvokeClient since there might be other actions (for ex: change_compartment) + # in the future which need the client generated by the generated module. + functions_management_client = self.client + self.client = functions_invoke_client + invoke_function_response = super(FunctionActionsHelperCustom, self).invoke() + # Read 1MB at a time + chunk_size = 1024 * 1024 + with open(to_bytes(dest), "wb") as dest_file: + for chunk in invoke_function_response.raw.stream( + chunk_size, decode_content=True + ): + dest_file.write(chunk) + return function + finally: + self.client = functions_management_client diff --git a/plugins/module_utils/oci_identity_custom_helpers.py b/plugins/module_utils/oci_identity_custom_helpers.py index bc9af9e0ab..4413b18b1b 100644 --- a/plugins/module_utils/oci_identity_custom_helpers.py +++ b/plugins/module_utils/oci_identity_custom_helpers.py @@ -74,32 +74,12 @@ def get_create_model(self): params_copy, self.get_create_model_class() ) - def list_resources(self): - optional_list_method_params = [] - + def get_required_kwargs_for_list(self): # the module 'compartment_id' parameter represents the unique identifier for a compartment # to be used by update and delete # any time we are listing compartments to do an idempotency check or to find a resource by name # we want to use 'parent_compartment_id' - required_kwargs = { - "compartment_id": self.module.params.get("parent_compartment_id") - } - - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) - - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) - - return oci_common_utils.list_all_resources( - self.client.list_compartments, **kwargs - ) + return {"compartment_id": self.module.params.get("parent_compartment_id")} class CompartmentFactsHelperCustom: @@ -261,11 +241,20 @@ def get_exclude_attributes(self): class UiPasswordHelperCustom: - - # there is no concept of idempotency for this module - # it re-executes create / reset password every time module is invoked - def get_matching_resource(self): - return None - def is_create(self): return True + + +class TagHelperCustom: + def get_update_model_dict_for_idempotence_check(self, update_model): + update_model_dict = super( + TagHelperCustom, self + ).get_update_model_dict_for_idempotence_check(update_model) + resource = self.get_resource().data + if ( + update_model_dict["validator"] + and update_model_dict["validator"]["validator_type"] == "DEFAULT" + and resource.validator is None + ): + update_model_dict["validator"] = None + return update_model_dict diff --git a/plugins/module_utils/oci_key_management_custom_helpers.py b/plugins/module_utils/oci_key_management_custom_helpers.py index f23350d373..07b9ee1286 100644 --- a/plugins/module_utils/oci_key_management_custom_helpers.py +++ b/plugins/module_utils/oci_key_management_custom_helpers.py @@ -40,33 +40,6 @@ def is_create(self): return True -class GeneratedKeyHelperCustom: - def get_module_resource_id(self): - return None - - # there is no concept of idempotency for this module - def get_matching_resource(self): - return None - - -class EncryptedDataHelperCustom: - def get_module_resource_id(self): - return None - - # there is no concept of idempotency for this module - def get_matching_resource(self): - return None - - -class DecryptedDataHelperCustom: - def get_module_resource_id(self): - return None - - # there is no concept of idempotency for this module - def get_matching_resource(self): - return None - - class VaultActionsHelperCustom: def is_action_necessary(self, action, resource): if kms_is_action_necessary(self, action, resource) is False: diff --git a/plugins/module_utils/oci_healthchecks_custom_helpers.py b/plugins/module_utils/oci_marketplace_custom_helpers.py similarity index 52% rename from plugins/module_utils/oci_healthchecks_custom_helpers.py rename to plugins/module_utils/oci_marketplace_custom_helpers.py index 140c91d33d..9cc35bef56 100644 --- a/plugins/module_utils/oci_healthchecks_custom_helpers.py +++ b/plugins/module_utils/oci_marketplace_custom_helpers.py @@ -3,31 +3,15 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Apache License v2.0 # See LICENSE.TXT for details. - from __future__ import absolute_import, division, print_function __metaclass__ = type -try: - - HAS_OCI_PY_SDK = True - -except ImportError: - HAS_OCI_PY_SDK = False - - -class HttpProbeHelperCustom: - def get_module_resource_id(self): - return None - - def list_resources(self): - return [] - - -class PingProbeHelperCustom: - def get_module_resource_id(self): - return None - - def list_resources(self): - return [] +class AcceptedAgreementHelperCustom: + # get model doesn't return `signature` of accepted aggreement. Thus, excluding + # `signature` for idempotency. + def get_exclude_attributes(self): + return super(AcceptedAgreementHelperCustom, self).get_exclude_attributes() + [ + "signature", + ] diff --git a/plugins/module_utils/oci_monitoring_custom_helpers.py b/plugins/module_utils/oci_monitoring_custom_helpers.py new file mode 100644 index 0000000000..432bc8fe3e --- /dev/null +++ b/plugins/module_utils/oci_monitoring_custom_helpers.py @@ -0,0 +1,73 @@ +# Copyright (c) 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_config_utils, +) + +try: + from oci.monitoring.models.metric import Metric + from oci.monitoring.models.metric_data import MetricData + from oci.monitoring.models.suppression import Suppression + from oci.monitoring import MonitoringClient + + HAS_OCI_PY_SDK = True + +except ImportError: + HAS_OCI_PY_SDK = False + + +class MetricActionsHelperCustom: + # this resource does not have get method. The customisation for `get_resource` is only to make the other functions + # work and to return some data to the user. + def get_resource(self): + return oci_common_utils.get_default_response_from_resource( + resource=oci_common_utils.convert_input_data_to_model_class( + self.module.params, Metric + ) + ) + + +class MetricDataActionsHelperCustom: + # this resource does not have get method. The customisation for `get_resource` is only to make the other functions + # work and to return some data to the user. + def get_resource(self): + return oci_common_utils.get_default_response_from_resource( + resource=oci_common_utils.convert_input_data_to_model_class( + self.module.params, MetricData + ) + ) + + +class SuppressionActionsHelperCustom: + # this resource does not have get method. The customisation for `get_resource` is only to make the other functions + # work and to return some data to the user. + def get_resource(self): + return oci_common_utils.get_default_response_from_resource( + resource=oci_common_utils.convert_input_data_to_model_class( + self.module.params, Suppression + ) + ) + + +class MetricDataHelperCustom: + # operation - PostMetricData uses the telemetry-ingestion endpoints; all other operations, use the telemetry + # endpoints. Providing `service_endpoint` argument explicitly to specify service endpoint used by this client. + def __init__(self, *args, **kwargs): + super(MetricDataHelperCustom, self).__init__(*args, **kwargs) + service_endpoint = str(self.client.base_client.endpoint) + self.module.params["service_endpoint"] = service_endpoint.replace( + "telemetry", "telemetry-ingestion" + ) + + self.client = oci_config_utils.create_service_client( + self.module, MonitoringClient + ) diff --git a/plugins/module_utils/oci_network_custom_helpers.py b/plugins/module_utils/oci_network_custom_helpers.py index fde5321789..ac4f4a6dd3 100644 --- a/plugins/module_utils/oci_network_custom_helpers.py +++ b/plugins/module_utils/oci_network_custom_helpers.py @@ -9,6 +9,7 @@ __metaclass__ = type from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible.module_utils._text import to_text try: from oci.exceptions import ServiceError, MaximumWaitTimeExceeded @@ -525,3 +526,81 @@ def get_update_model(self): ) ] return update_model + + +def patch_base_client_call_api(client): + if not client: + return + if not hasattr(client, "base_client"): + return + if not hasattr(client.base_client, "call_api"): + return + original_call_api = client.base_client.call_api + + def call_api(*args, **kwargs): + header_params = kwargs.pop("header_params", {}) + _debug(header_params) + for header_key in header_params: + if ( + header_key == "accept" + and header_params[header_key] == "text/plain; charset=utf-8" + ): + header_params[header_key] = "*/*" + _debug(header_params) + return original_call_api(*args, header_params=header_params, **kwargs) + + client.base_client.call_api = call_api + + +class CpeConfigContentFactsHelperCustom: + def __init__(self, *args, **kwargs): + super(CpeConfigContentFactsHelperCustom, self).__init__(*args, **kwargs) + # Currently the server throws an error with the default Accept header added by the SDK. But if we remove the + # charset parameter from the header, it works fine. + # TODO: Remove this once the issue with API is fixed + patch_base_client_call_api(self.client) + + def get(self): + response_data = self.get_resource().data + return to_text(response_data.content) + + +class IpSecConnectionCpeConfigContentFactsHelperCustom: + def __init__(self, *args, **kwargs): + super(IpSecConnectionCpeConfigContentFactsHelperCustom, self).__init__( + *args, **kwargs + ) + # Currently the server throws an error with the default Accept header added by the SDK. But if we remove the + # charset parameter from the header, it works fine. + # TODO: Remove this once the issue with API is fixed + patch_base_client_call_api(self.client) + + def get(self): + response_data = self.get_resource().data + return to_text(response_data.content) + + +class IpSecConnectionTunnelCpeDeviceConfigHelperCustom: + def get_update_model_dict_for_idempotence_check(self, update_model): + # The device config param has different names in update model (tunnel_cpe_device_config) and get model + # (tunnel_cpe_device_config_parameter). So update the name in the update model for idempotence logic to work. + update_model_dict = to_dict(update_model) + update_model_dict["tunnel_cpe_device_config_parameter"] = update_model_dict.pop( + "tunnel_cpe_device_config", None + ) + return update_model_dict + + +class IpSecConnectionTunnelCpeDeviceConfigContentFactsHelperCustom: + def __init__(self, *args, **kwargs): + super( + IpSecConnectionTunnelCpeDeviceConfigContentFactsHelperCustom, self + ).__init__(*args, **kwargs) + # Currently the server throws an error with the default Accept header added by the SDK. But if we remove the + # charset parameter from the header, it works fine. + # TODO: Remove this once the issue with API is fixed + patch_base_client_call_api(self.client) + + def get(self): + response_data = self.get_resource().data + return to_text(response_data.content) diff --git a/plugins/module_utils/oci_ons_custom_helpers.py b/plugins/module_utils/oci_ons_custom_helpers.py new file mode 100644 index 0000000000..a3c3e8f765 --- /dev/null +++ b/plugins/module_utils/oci_ons_custom_helpers.py @@ -0,0 +1,25 @@ +# Copyright (c) 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. + +from __future__ import absolute_import, division, print_function +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils + +__metaclass__ = type + + +class NotificationTopicHelperCustom: + def get_get_model_from_summary_model(self, summary_model): + return self.client.get_topic(topic_id=summary_model.topic_id).data + + +class SubscriptionActionsHelperCustom: + # the get_ have been re-written as the actions_module expects the `id` parameter as an input + # but fetches the subscription resource using the `subscription_id` parameter. This inconsistency starts + # throwing error as the ONS service expects the subscriptionId parameter to fetch the resource. + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_subscription, subscription_id=self.module.params.get("id"), + ) diff --git a/plugins/module_utils/oci_resource_utils.py b/plugins/module_utils/oci_resource_utils.py index bc3e3fa3de..0de8469865 100644 --- a/plugins/module_utils/oci_resource_utils.py +++ b/plugins/module_utils/oci_resource_utils.py @@ -11,13 +11,13 @@ from ansible_collections.oracle.oci.plugins.module_utils import ( oci_config_utils, oci_common_utils, + oci_custom_helpers_utils, ) from ansible_collections.oracle.oci.plugins.module_utils.oci_common_utils import ( pretty_print_json, ) -import inspect import os try: @@ -63,6 +63,9 @@ def is_summary_model(self, resource): return False return False + def get_resource_failed_states(self): + return oci_common_utils.FAILED_STATES + class OCIResourceFactsHelperBase(OCIResourceCommonBase): def __init__(self, module, resource_type, service_client_class, namespace): @@ -88,6 +91,18 @@ def get_resource(self): """Expected to be generated inside the module.""" raise NotImplementedError("get not supported by {0}".format(self.resource_type)) + def get_required_kwargs_for_list(self): + """Expected to be generated inside the module.""" + raise NotImplementedError( + "list not supported by {0}".format(self.resource_type) + ) + + def get_optional_kwargs_for_list(self): + """Expected to be generated inside the module.""" + raise NotImplementedError( + "list not supported by {0}".format(self.resource_type) + ) + def list_resources(self): """Expected to be generated inside the module.""" raise NotImplementedError( @@ -283,6 +298,18 @@ def get_resource(self): """Expected to be generated inside the module.""" raise NotImplementedError("get not supported by {0}".format(self.resource_type)) + def get_required_kwargs_for_list(self): + """Expected to be generated inside the module.""" + raise NotImplementedError( + "list not supported by {0}".format(self.resource_type) + ) + + def get_optional_kwargs_for_list(self): + """Expected to be generated inside the module.""" + raise NotImplementedError( + "list not supported by {0}".format(self.resource_type) + ) + def list_resources(self): """Expected to be generated inside the module.""" raise NotImplementedError( @@ -301,6 +328,12 @@ def update_resource(self): "update not supported by {0}".format(self.resource_type) ) + def patch_resource(self): + """Expected to be generated inside the module.""" + raise NotImplementedError( + "patch not supported by {0}".format(self.resource_type) + ) + def delete_resource(self): """Expected to be generated inside the module.""" raise NotImplementedError( @@ -315,6 +348,10 @@ def get_update_model_class(self): """Expected to be generated inside the module.""" pass + def get_patch_model_class(self): + """Expected to be generated inside the module.""" + pass + def get_resource_active_states(self): return oci_common_utils.DEFAULT_READY_STATES @@ -373,6 +410,13 @@ def is_update(self): return False return True + def is_patch(self): + if not self.module.params.get("state") == "present": + return False + if not self.get_module_resource_id(): + return False + return True + def is_create(self): if not self.module.params.get("state") == "present": return False @@ -515,6 +559,11 @@ def get_update_model(self): self.module.params, self.get_update_model_class() ) + def get_patch_model(self): + return oci_common_utils.convert_input_data_to_model_class( + self.module.params, self.get_patch_model_class() + ) + def get_update_model_dict_for_idempotence_check(self, update_model): """This function allows any customisations that are needed in the update model for comparison during the idempotence check. @@ -524,6 +573,15 @@ def get_update_model_dict_for_idempotence_check(self, update_model): and stores it differently etc.""" return to_dict(update_model) + def get_patch_model_dict_for_idempotence_check(self, update_model): + """This function allows any customisations that are needed in the patch model for comparison during the + idempotence check. + + This can be done for many reasons. For ex: some resource have different names for same parameter in update + and get model making the idempotence logic to fail or we may need to update a value since the server computes + and stores it differently etc.""" + return to_dict(update_model) + def get_user_provided_value(self, attr): return self.module.params.get(attr) @@ -674,14 +732,24 @@ def create(self): resource=to_dict(created_resource), ) - def is_update_necessary(self): - current_resource_dict = to_dict(self.get_resource().data) + def get_existing_resource_dict_for_update(self): + try: + get_response = self.get_resource() + except ServiceError as se: + self.module.fail_json( + msg="Getting resource failed with exception: {0}".format(se.message) + ) + else: + return to_dict(get_response.data) + + def is_update_necessary(self, existing_resource_dict): + update_model = self.get_update_model() update_model_dict = self.get_update_model_dict_for_idempotence_check( update_model ) update_is_necessary = not oci_common_utils.compare_dicts( - update_model_dict, current_resource_dict + update_model_dict, existing_resource_dict ) _debug( @@ -693,8 +761,53 @@ def is_update_necessary(self): return update_is_necessary + def is_patch_necessary(self, existing_resource_dict): + + patch_model = self.get_patch_model() + patch_model_dict = self.get_patch_model_dict_for_idempotence_check(patch_model) + patch_is_necessary = not oci_common_utils.compare_dicts( + patch_model_dict, existing_resource_dict + ) + + _debug( + "is patch necessary for {resource_type}: {patch_is_necessary}".format( + resource_type=self.resource_type, patch_is_necessary=patch_is_necessary, + ) + ) + + return patch_is_necessary + def update(self): + resource = self.get_existing_resource_dict_for_update() + is_update_necessary = self.is_update_necessary(resource) + if not is_update_necessary: + return self.prepare_result( + changed=False, resource_type=self.resource_type, resource=resource + ) + + if self.check_mode: + return self.prepare_result( + changed=True, resource_type=self.resource_type, resource=resource + ) + + try: + updated_resource = self.update_resource() + except MaximumWaitTimeExceeded as mwtex: + self.module.fail_json(msg=str(mwtex)) + except ServiceError as se: + self.module.fail_json( + msg="Updating resource failed with exception: {0}".format(se.message) + ) + else: + return self.prepare_result( + changed=True, + resource_type=self.resource_type, + resource=to_dict(updated_resource), + ) + + def patch(self): + try: get_response = self.get_resource() except ServiceError as se: @@ -704,7 +817,7 @@ def update(self): else: resource = to_dict(get_response.data) - is_update_necessary = self.is_update_necessary() + is_update_necessary = self.is_patch_necessary(resource) if not is_update_necessary: return self.prepare_result( changed=False, resource_type=self.resource_type, resource=resource @@ -716,18 +829,18 @@ def update(self): ) try: - updated_resource = self.update_resource() + patched_resource = self.patch_resource() except MaximumWaitTimeExceeded as mwtex: self.module.fail_json(msg=str(mwtex)) except ServiceError as se: self.module.fail_json( - msg="Updating resource failed with exception: {0}".format(se.message) + msg="Patching resource failed with exception: {0}".format(se.message) ) else: return self.prepare_result( changed=True, resource_type=self.resource_type, - resource=to_dict(updated_resource), + resource=to_dict(patched_resource), ) def delete(self): @@ -815,7 +928,7 @@ def update_using_name(self): resource = to_dict(get_response.data) self.set_required_ids_in_module_when_name_is_identifier(resource) - is_update_necessary = self.is_update_necessary() + is_update_necessary = self.is_update_necessary(resource) if not is_update_necessary: return self.prepare_result( changed=False, resource_type=self.resource_type, resource=resource @@ -841,6 +954,44 @@ def update_using_name(self): resource=to_dict(updated_resource), ) + def patch_using_name(self): + + try: + get_response = self.get_resource_using_name() + except ServiceError as se: + self.module.fail_json( + msg="Getting resource failed with exception: {0}".format(se.message) + ) + else: + resource = to_dict(get_response.data) + + self.set_required_ids_in_module_when_name_is_identifier(resource) + is_patch_necessary = self.is_patch_necessary(resource) + if not is_patch_necessary: + return self.prepare_result( + changed=False, resource_type=self.resource_type, resource=resource + ) + + if self.check_mode: + return self.prepare_result( + changed=True, resource_type=self.resource_type, resource=resource + ) + + try: + patched_resource = self.patch_resource() + except MaximumWaitTimeExceeded as mwtex: + self.module.fail_json(msg=str(mwtex)) + except ServiceError as se: + self.module.fail_json( + msg="Patching resource failed with exception: {0}".format(se.message) + ) + else: + return self.prepare_result( + changed=True, + resource_type=self.resource_type, + resource=to_dict(patched_resource), + ) + def delete_using_name(self): try: @@ -895,66 +1046,13 @@ def delete_using_name(self): ) -def get_custom_class_mapping(modules): - """Find the custom classes in the given modules and return a mapping with class name as key and class as value""" - custom_class_mapping = {} - for module in modules: - for obj_name in dir(module): - if not obj_name.endswith("Custom"): - continue - obj = getattr(module, obj_name) - if inspect.isclass(obj): - custom_class_mapping[obj_name] = obj - return custom_class_mapping - - -# Due to the generalisations made about the resource APIs or because of the ease of use enhancements, the generated -# modules might not always be perfect. The custom behaviour is handled by having a custom class which is used to -# override the generated behaviour. Create a mapping of those custom classes so that we can dynamically override -# the behaviour. -# import the customisation files. -from ansible_collections.oracle.oci.plugins.module_utils import ( - oci_identity_custom_helpers, - oci_network_custom_helpers, - oci_compute_custom_helpers, - oci_blockstorage_custom_helpers, - oci_compute_management_custom_helpers, - oci_audit_custom_helpers, - oci_object_storage_custom_helpers, - oci_key_management_custom_helpers, - oci_file_storage_custom_helpers, - oci_healthchecks_custom_helpers, - oci_container_engine_custom_helpers, - oci_load_balancer_custom_helpers, - oci_database_custom_helpers, -) # noqa - -custom_helper_mapping = get_custom_class_mapping( - [ - oci_identity_custom_helpers, - oci_network_custom_helpers, - oci_compute_custom_helpers, - oci_blockstorage_custom_helpers, - oci_compute_management_custom_helpers, - oci_audit_custom_helpers, - oci_object_storage_custom_helpers, - oci_key_management_custom_helpers, - oci_file_storage_custom_helpers, - oci_healthchecks_custom_helpers, - oci_container_engine_custom_helpers, - oci_load_balancer_custom_helpers, - oci_database_custom_helpers, - ] -) - - class DefaultHelperCustom: """Default class with no customizations""" def get_custom_class(custom_class_name): """Return the custom class from mapping using the given name if exists, else return the default custom class.""" - custom_class = custom_helper_mapping.get(custom_class_name) + custom_class = oci_custom_helpers_utils.custom_helper_mapping.get(custom_class_name) if not custom_class: return DefaultHelperCustom return custom_class diff --git a/plugins/module_utils/oci_streaming_custom_helpers.py b/plugins/module_utils/oci_streaming_custom_helpers.py new file mode 100644 index 0000000000..4e1acb9882 --- /dev/null +++ b/plugins/module_utils/oci_streaming_custom_helpers.py @@ -0,0 +1,45 @@ +# Copyright (c) 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils + + +logger = oci_common_utils.get_logger("oci_stream_custom_helpers") + + +def _debug(s): + get_logger().debug(s) + + +def get_logger(): + return logger + + +class StreamPoolHelperCustom: + # Some attrs end with details and the get returns the same field without details + # This case we should still match them for update and create + def get_existing_resource_dict_for_idempotence_check(self, existing_resource): + existing_resource_dict = super( + StreamPoolHelperCustom, self + ).get_existing_resource_dict_for_idempotence_check(existing_resource) + if existing_resource_dict.get("custom_encryption_key"): + existing_resource_dict[ + "custom_encryption_key_details" + ] = existing_resource_dict.pop("custom_encryption_key") + return existing_resource_dict + + def is_update_necessary(self, existing_resource_dict): + if existing_resource_dict.get("custom_encryption_key"): + existing_resource_dict[ + "custom_encryption_key_details" + ] = existing_resource_dict.get("custom_encryption_key") + return super(StreamPoolHelperCustom, self).is_update_necessary( + existing_resource_dict + ) diff --git a/plugins/module_utils/oci_version.py b/plugins/module_utils/oci_version.py index 93cd9fe1d6..b8e25c8e07 100644 --- a/plugins/module_utils/oci_version.py +++ b/plugins/module_utils/oci_version.py @@ -4,4 +4,4 @@ # Apache License v2.0 # See LICENSE.TXT for details. -__version__ = "2.1.2-beta" +__version__ = "2.2.0" diff --git a/plugins/module_utils/oci_wait_utils.py b/plugins/module_utils/oci_wait_utils.py index 3564b5b5ac..c64e3ddcb2 100644 --- a/plugins/module_utils/oci_wait_utils.py +++ b/plugins/module_utils/oci_wait_utils.py @@ -128,6 +128,18 @@ def get_evaluate_response_lambda(self): and getattr(r.data, "lifecycle_state").lower() in lowered_wait_for_states ) + def verify_operation_succeeded(self, wait_response): + if wait_response.data and hasattr(wait_response.data, "lifecycle_state"): + if ( + wait_response.data.lifecycle_state + in self.resource_helper.get_resource_failed_states() + ): + self.resource_helper.module.fail_json( + msg="Operation failed as resource entered into a failure state: {failure_state}".format( + failure_state=wait_response.data.lifecycle_state + ) + ) + def get_resource_from_wait_response(self, wait_response): return wait_response.data @@ -423,6 +435,8 @@ def get_resource_from_wait_response(self, wait_response): class InstanceConfigurationLaunchInstanceWorkRequestWaiter(WorkRequestWaiter): + # launch action creates an instance. So it makes more sense to return the created instance but the default + # implementation returns the instance_configuration. So override to return the created instance instead. def get_resource_from_wait_response(self, wait_response): if not ( hasattr(wait_response.data, "resources") and wait_response.data.resources @@ -684,6 +698,16 @@ def get_waiter( return NoneWaiter(client, resource_helper, operation_response, wait_for_states) +def get_wait_for_states_with_failed_states(wait_for_states, resource_helper): + try: + resource_failure_states = resource_helper.get_resource_failed_states() + if resource_failure_states: + wait_for_states = list(set(wait_for_states + resource_failure_states)) + except NotImplementedError: + pass + return wait_for_states + + def call_and_wait( call_fn, call_fn_args, @@ -698,6 +722,12 @@ def call_and_wait( operation_response = oci_common_utils.call_with_backoff( call_fn, *call_fn_args, **call_fn_kwargs ) + # Add the failure states so that when an operation fails and the resource goes into failed state we fail and don't + # wait until the timeout. This seems to be a good place to put this instead of duplicating it in multiple places. + if waiter_type == LIFECYCLE_STATE_WAITER_KEY: + wait_for_states = get_wait_for_states_with_failed_states( + wait_for_states, resource_helper + ) waiter = get_waiter( waiter_type, operation, diff --git a/plugins/modules/oci_audit_configuration.py b/plugins/modules/oci_audit_configuration.py index af74b2857c..384946dfe2 100644 --- a/plugins/modules/oci_audit_configuration.py +++ b/plugins/modules/oci_audit_configuration.py @@ -23,7 +23,8 @@ short_description: Manage a Configuration resource in Oracle Cloud Infrastructure description: - This module allows the user to update a Configuration resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -44,10 +45,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_audit_configuration_facts.py b/plugins/modules/oci_audit_configuration_facts.py index e997126962..9dadc861c4 100644 --- a/plugins/modules/oci_audit_configuration_facts.py +++ b/plugins/modules/oci_audit_configuration_facts.py @@ -31,10 +31,7 @@ - ID of the root compartment (tenancy) type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_audit_event_facts.py b/plugins/modules/oci_audit_event_facts.py index 621343ce60..39f4bca113 100644 --- a/plugins/modules/oci_audit_event_facts.py +++ b/plugins/modules/oci_audit_event_facts.py @@ -53,10 +53,7 @@ granularity to the minute. Seconds (and milliseconds, if included) must be set to `0`. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_autoscaling_auto_scaling_configuration.py b/plugins/modules/oci_autoscaling_auto_scaling_configuration.py index 93e28c207c..3346835a15 100644 --- a/plugins/modules/oci_autoscaling_auto_scaling_configuration.py +++ b/plugins/modules/oci_autoscaling_auto_scaling_configuration.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete an AutoScalingConfiguration resource in Oracle Cloud Infrastructure - For I(state=present), creates an autoscaling configuration. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -203,10 +204,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -561,31 +558,36 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_auto_scaling_configurations, **kwargs ) diff --git a/plugins/modules/oci_autoscaling_auto_scaling_configuration_facts.py b/plugins/modules/oci_autoscaling_auto_scaling_configuration_facts.py index a5983f8a9f..7008fc8a4d 100644 --- a/plugins/modules/oci_autoscaling_auto_scaling_configuration_facts.py +++ b/plugins/modules/oci_autoscaling_auto_scaling_configuration_facts.py @@ -62,10 +62,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy.py b/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy.py index e194f31fb4..3d3bbc5527 100644 --- a/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy.py +++ b/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy.py @@ -23,7 +23,8 @@ short_description: Manage an AutoScalingConfigurationPolicy resource in Oracle Cloud Infrastructure description: - This module allows the user to update an AutoScalingConfigurationPolicy resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: auto_scaling_configuration_id: description: @@ -144,10 +145,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -382,31 +379,36 @@ def get_resource(self): auto_scaling_policy_id=self.module.params.get("auto_scaling_policy_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "auto_scaling_configuration_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_auto_scaling_policies, **kwargs ) diff --git a/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy_facts.py b/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy_facts.py index 435bf94841..8018af62d5 100644 --- a/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy_facts.py +++ b/plugins/modules/oci_autoscaling_auto_scaling_configuration_policy_facts.py @@ -60,10 +60,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_boot_volume.py b/plugins/modules/oci_blockstorage_boot_volume.py index 564149a303..2cfd3f2384 100644 --- a/plugins/modules/oci_blockstorage_boot_volume.py +++ b/plugins/modules/oci_blockstorage_boot_volume.py @@ -27,7 +27,8 @@ For general information about boot volumes, see L(Boot Volumes,https://docs.cloud.oracle.com/Content/Block/Concepts/bootvolumes.htm). You may optionally specify a *display name* for the volume, which is simply a friendly name or description. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -115,10 +116,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -346,30 +343,24 @@ def get_resource(self): boot_volume_id=self.module.params.get("boot_volume_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "availability_domain", "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_boot_volumes, **kwargs ) diff --git a/plugins/modules/oci_blockstorage_boot_volume_backup.py b/plugins/modules/oci_blockstorage_boot_volume_backup.py index 0fd7c51d36..249a07f9ea 100644 --- a/plugins/modules/oci_blockstorage_boot_volume_backup.py +++ b/plugins/modules/oci_blockstorage_boot_volume_backup.py @@ -29,7 +29,8 @@ When the data is imaged, it goes into a CREATING state. After the backup is fully uploaded to the cloud, it goes into an AVAILABLE state. - "This resource has the following action operations in the M(oci_boot_volume_backup_actions) module: copy." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: boot_volume_id: description: @@ -86,10 +87,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -306,32 +303,36 @@ def get_resource(self): boot_volume_backup_id=self.module.params.get("boot_volume_backup_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "boot_volume_id", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["boot_volume_id", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_boot_volume_backups, **kwargs ) diff --git a/plugins/modules/oci_blockstorage_boot_volume_backup_actions.py b/plugins/modules/oci_blockstorage_boot_volume_backup_actions.py index 49ffdb98d4..47a641b778 100644 --- a/plugins/modules/oci_blockstorage_boot_volume_backup_actions.py +++ b/plugins/modules/oci_blockstorage_boot_volume_backup_actions.py @@ -50,11 +50,9 @@ - The action to perform on the BootVolumeBackup. type: str required: true - choices: ["copy"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "copy" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_blockstorage_boot_volume_backup_facts.py b/plugins/modules/oci_blockstorage_boot_volume_backup_facts.py index d7a9d7253f..6c83cc0507 100644 --- a/plugins/modules/oci_blockstorage_boot_volume_backup_facts.py +++ b/plugins/modules/oci_blockstorage_boot_volume_backup_facts.py @@ -83,10 +83,7 @@ - "TERMINATED" - "FAULTY" - "REQUEST_RECEIVED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_boot_volume_facts.py b/plugins/modules/oci_blockstorage_boot_volume_facts.py index e7021e8281..d6b1acd282 100644 --- a/plugins/modules/oci_blockstorage_boot_volume_facts.py +++ b/plugins/modules/oci_blockstorage_boot_volume_facts.py @@ -48,10 +48,7 @@ description: - The OCID of the volume group. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_blockstorage_boot_volume_kms_key.py b/plugins/modules/oci_blockstorage_boot_volume_kms_key.py index fab9bc9311..6af0f89507 100644 --- a/plugins/modules/oci_blockstorage_boot_volume_kms_key.py +++ b/plugins/modules/oci_blockstorage_boot_volume_kms_key.py @@ -23,7 +23,8 @@ short_description: Manage a BootVolumeKmsKey resource in Oracle Cloud Infrastructure description: - This module allows the user to update and delete a BootVolumeKmsKey resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: boot_volume_id: description: @@ -46,10 +47,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_boot_volume_kms_key_facts.py b/plugins/modules/oci_blockstorage_boot_volume_kms_key_facts.py index 9ef2f841c9..e4e82c3f9c 100644 --- a/plugins/modules/oci_blockstorage_boot_volume_kms_key_facts.py +++ b/plugins/modules/oci_blockstorage_boot_volume_kms_key_facts.py @@ -32,10 +32,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_volume.py b/plugins/modules/oci_blockstorage_volume.py index 1255efcd1e..015285eaed 100644 --- a/plugins/modules/oci_blockstorage_volume.py +++ b/plugins/modules/oci_blockstorage_volume.py @@ -35,7 +35,8 @@ in the Identity and Access Management Service API. - "You may optionally specify a *display name* for the volume, which is simply a friendly name or description. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -132,10 +133,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -349,32 +346,36 @@ def get_resource(self): self.client.get_volume, volume_id=self.module.params.get("volume_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "availability_domain", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["availability_domain", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_volumes, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_blockstorage_volume_backup.py b/plugins/modules/oci_blockstorage_volume_backup.py index fcadda966f..171d711225 100644 --- a/plugins/modules/oci_blockstorage_volume_backup.py +++ b/plugins/modules/oci_blockstorage_volume_backup.py @@ -29,7 +29,8 @@ When the data is imaged, it goes into a CREATING state. After the backup is fully uploaded to the cloud, it goes into an AVAILABLE state. - "This resource has the following action operations in the M(oci_volume_backup_actions) module: copy." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: defined_tags: description: @@ -86,10 +87,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -316,32 +313,36 @@ def get_resource(self): volume_backup_id=self.module.params.get("volume_backup_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "volume_id", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["volume_id", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_volume_backups, **kwargs ) diff --git a/plugins/modules/oci_blockstorage_volume_backup_actions.py b/plugins/modules/oci_blockstorage_volume_backup_actions.py index f43290f6eb..2915257c94 100644 --- a/plugins/modules/oci_blockstorage_volume_backup_actions.py +++ b/plugins/modules/oci_blockstorage_volume_backup_actions.py @@ -50,11 +50,9 @@ - The action to perform on the VolumeBackup. type: str required: true - choices: ["copy"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "copy" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_blockstorage_volume_backup_facts.py b/plugins/modules/oci_blockstorage_volume_backup_facts.py index edfc54392f..a34a2566a7 100644 --- a/plugins/modules/oci_blockstorage_volume_backup_facts.py +++ b/plugins/modules/oci_blockstorage_volume_backup_facts.py @@ -83,10 +83,7 @@ - "TERMINATED" - "FAULTY" - "REQUEST_RECEIVED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_volume_backup_policy.py b/plugins/modules/oci_blockstorage_volume_backup_policy.py index 71b59f6fe6..a4e4c4e945 100644 --- a/plugins/modules/oci_blockstorage_volume_backup_policy.py +++ b/plugins/modules/oci_blockstorage_volume_backup_policy.py @@ -26,7 +26,8 @@ - For I(state=present), creates a new user defined backup policy. - For more information about Oracle defined backup policies and user defined backup policies, see L(Policy-Based Backups,https://docs.cloud.oracle.com/iaas/Content/Block/Tasks/schedulingvolumebackups.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -167,10 +168,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -397,29 +394,30 @@ def get_resource(self): policy_id=self.module.params.get("policy_id"), ) - def list_resources(self): - required_list_method_params = [] - - optional_list_method_params = [ - "compartment_id", - ] + def get_required_kwargs_for_list(self): + return dict() - required_kwargs = dict( - (param, self.module.params[param]) for param in required_list_method_params - ) + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["compartment_id"] - optional_kwargs = dict( + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_volume_backup_policies, **kwargs ) diff --git a/plugins/modules/oci_blockstorage_volume_backup_policy_assignment.py b/plugins/modules/oci_blockstorage_volume_backup_policy_assignment.py index e9825edbad..87a4c8965a 100644 --- a/plugins/modules/oci_blockstorage_volume_backup_policy_assignment.py +++ b/plugins/modules/oci_blockstorage_volume_backup_policy_assignment.py @@ -26,7 +26,8 @@ - For I(state=present), assigns a volume backup policy to the specified volume. Note that a given volume can only have one backup policy assigned to it. If this operation is used for a volume that already has a different backup policy assigned, the prior backup policy will be silently unassigned. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: asset_id: description: @@ -53,10 +54,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -149,29 +146,23 @@ def get_resource(self): policy_assignment_id=self.module.params.get("policy_assignment_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "asset_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.get_volume_backup_policy_asset_assignment, **kwargs ) diff --git a/plugins/modules/oci_blockstorage_volume_backup_policy_assignment_facts.py b/plugins/modules/oci_blockstorage_volume_backup_policy_assignment_facts.py index 8e89e3142a..025bd05f36 100644 --- a/plugins/modules/oci_blockstorage_volume_backup_policy_assignment_facts.py +++ b/plugins/modules/oci_blockstorage_volume_backup_policy_assignment_facts.py @@ -40,10 +40,7 @@ - The OCID of an asset (e.g. a volume). - Required to list multiple volume_backup_policy_assignments. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_volume_backup_policy_facts.py b/plugins/modules/oci_blockstorage_volume_backup_policy_facts.py index c1aa5b57bb..2268ff297d 100644 --- a/plugins/modules/oci_blockstorage_volume_backup_policy_facts.py +++ b/plugins/modules/oci_blockstorage_volume_backup_policy_facts.py @@ -40,10 +40,7 @@ - The OCID of the compartment. If no compartment is specified, the Oracle defined backup policies are listed. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_blockstorage_volume_facts.py b/plugins/modules/oci_blockstorage_volume_facts.py index dcd1c34af9..edc3b5d439 100644 --- a/plugins/modules/oci_blockstorage_volume_facts.py +++ b/plugins/modules/oci_blockstorage_volume_facts.py @@ -84,10 +84,7 @@ - "TERMINATING" - "TERMINATED" - "FAULTY" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_volume_group.py b/plugins/modules/oci_blockstorage_volume_group.py index 1f8320b872..0f35ab9901 100644 --- a/plugins/modules/oci_blockstorage_volume_group.py +++ b/plugins/modules/oci_blockstorage_volume_group.py @@ -29,7 +29,8 @@ You may optionally specify a *display name* for the volume group, which is simply a friendly name or description. It does not have to be unique, and you can change it. Avoid entering confidential information." - For more information, see L(Volume Groups,https://docs.cloud.oracle.com/Content/Block/Concepts/volumegroups.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -113,10 +114,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -331,32 +328,36 @@ def get_resource(self): volume_group_id=self.module.params.get("volume_group_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "availability_domain", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["availability_domain", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_volume_groups, **kwargs ) diff --git a/plugins/modules/oci_blockstorage_volume_group_backup.py b/plugins/modules/oci_blockstorage_volume_group_backup.py index 175e0c7e23..a9d1aa0901 100644 --- a/plugins/modules/oci_blockstorage_volume_group_backup.py +++ b/plugins/modules/oci_blockstorage_volume_group_backup.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a VolumeGroupBackup resource in Oracle Cloud Infrastructure - For I(state=present), creates a new backup volume group of the specified volume group. For more information, see L(Volume Groups,https://docs.cloud.oracle.com/Content/Block/Concepts/volumegroups.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -83,10 +84,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -286,32 +283,36 @@ def get_resource(self): volume_group_backup_id=self.module.params.get("volume_group_backup_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "volume_group_id", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["volume_group_id", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_volume_group_backups, **kwargs ) diff --git a/plugins/modules/oci_blockstorage_volume_group_backup_facts.py b/plugins/modules/oci_blockstorage_volume_group_backup_facts.py index 30aa20cd57..3a7168e680 100644 --- a/plugins/modules/oci_blockstorage_volume_group_backup_facts.py +++ b/plugins/modules/oci_blockstorage_volume_group_backup_facts.py @@ -69,10 +69,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_volume_group_facts.py b/plugins/modules/oci_blockstorage_volume_group_facts.py index 50cf79ddaa..981da7e8f4 100644 --- a/plugins/modules/oci_blockstorage_volume_group_facts.py +++ b/plugins/modules/oci_blockstorage_volume_group_facts.py @@ -80,10 +80,7 @@ - "TERMINATING" - "TERMINATED" - "FAULTY" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_volume_kms_key.py b/plugins/modules/oci_blockstorage_volume_kms_key.py index c17bc7a89c..b3504c92c5 100644 --- a/plugins/modules/oci_blockstorage_volume_kms_key.py +++ b/plugins/modules/oci_blockstorage_volume_kms_key.py @@ -23,7 +23,8 @@ short_description: Manage a VolumeKmsKey resource in Oracle Cloud Infrastructure description: - This module allows the user to update and delete a VolumeKmsKey resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: volume_id: description: @@ -46,10 +47,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_blockstorage_volume_kms_key_facts.py b/plugins/modules/oci_blockstorage_volume_kms_key_facts.py index b9c147756d..b80336986a 100644 --- a/plugins/modules/oci_blockstorage_volume_kms_key_facts.py +++ b/plugins/modules/oci_blockstorage_volume_kms_key_facts.py @@ -32,10 +32,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_budget.py b/plugins/modules/oci_budget.py index 5e468a25b3..632b1d01f7 100644 --- a/plugins/modules/oci_budget.py +++ b/plugins/modules/oci_budget.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a Budget resource in Oracle Cloud Infrastructure - For I(state=present), creates a new Budget. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -88,10 +89,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -303,31 +300,36 @@ def get_resource(self): self.client.get_budget, budget_id=self.module.params.get("budget_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_budgets, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_budget_alert_rule.py b/plugins/modules/oci_budget_alert_rule.py index fe282f2312..6043f23b53 100644 --- a/plugins/modules/oci_budget_alert_rule.py +++ b/plugins/modules/oci_budget_alert_rule.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a BudgetAlertRule resource in Oracle Cloud Infrastructure - For I(state=present), creates a new Alert Rule. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: budget_id: description: @@ -102,10 +103,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -312,31 +309,36 @@ def get_resource(self): alert_rule_id=self.module.params.get("alert_rule_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "budget_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_alert_rules, **kwargs ) diff --git a/plugins/modules/oci_budget_alert_rule_facts.py b/plugins/modules/oci_budget_alert_rule_facts.py index 01ff1cd5a7..55b9085c26 100644 --- a/plugins/modules/oci_budget_alert_rule_facts.py +++ b/plugins/modules/oci_budget_alert_rule_facts.py @@ -67,10 +67,7 @@ - "Example: `My new resource`" type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_budget_facts.py b/plugins/modules/oci_budget_facts.py index 72db4cebc9..9042bbf9ff 100644 --- a/plugins/modules/oci_budget_facts.py +++ b/plugins/modules/oci_budget_facts.py @@ -67,10 +67,7 @@ - "Example: `My new resource`" type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_app_catalog_listing_facts.py b/plugins/modules/oci_compute_app_catalog_listing_facts.py index 5d7487f860..11e23cab04 100644 --- a/plugins/modules/oci_compute_app_catalog_listing_facts.py +++ b/plugins/modules/oci_compute_app_catalog_listing_facts.py @@ -54,10 +54,7 @@ - A filter to return only resources that match the given display name exactly. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_app_catalog_listing_resource_version_agreement_facts.py b/plugins/modules/oci_compute_app_catalog_listing_resource_version_agreement_facts.py index 79711f3beb..74d46841b8 100644 --- a/plugins/modules/oci_compute_app_catalog_listing_resource_version_agreement_facts.py +++ b/plugins/modules/oci_compute_app_catalog_listing_resource_version_agreement_facts.py @@ -38,10 +38,7 @@ type: str aliases: ["version"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_app_catalog_listing_resource_version_facts.py b/plugins/modules/oci_compute_app_catalog_listing_resource_version_facts.py index 5434fb2807..0617b5c9ea 100644 --- a/plugins/modules/oci_compute_app_catalog_listing_resource_version_facts.py +++ b/plugins/modules/oci_compute_app_catalog_listing_resource_version_facts.py @@ -46,10 +46,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_app_catalog_subscription.py b/plugins/modules/oci_compute_app_catalog_subscription.py index 828bba8e33..78b119eadd 100644 --- a/plugins/modules/oci_compute_app_catalog_subscription.py +++ b/plugins/modules/oci_compute_app_catalog_subscription.py @@ -24,7 +24,8 @@ description: - This module allows the user to create and delete an AppCatalogSubscription resource in Oracle Cloud Infrastructure - For I(state=present), create a subscription for listing resource version for a compartment. It will take some time to propagate to all regions. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -70,10 +71,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -188,31 +185,36 @@ class AppCatalogSubscriptionHelperGen(OCIResourceHelperBase): # needs custom GET via LIST implementation because resource does not have an 'id' field - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "listing_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["listing_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_app_catalog_subscriptions, **kwargs ) diff --git a/plugins/modules/oci_compute_app_catalog_subscription_facts.py b/plugins/modules/oci_compute_app_catalog_subscription_facts.py index f26af43a61..15a95cd897 100644 --- a/plugins/modules/oci_compute_app_catalog_subscription_facts.py +++ b/plugins/modules/oci_compute_app_catalog_subscription_facts.py @@ -56,10 +56,7 @@ description: - A filter to return only the listings that matches the given listing id. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_compute_boot_volume_attachment.py b/plugins/modules/oci_compute_boot_volume_attachment.py index 308a2a7702..385bf1579c 100644 --- a/plugins/modules/oci_compute_boot_volume_attachment.py +++ b/plugins/modules/oci_compute_boot_volume_attachment.py @@ -24,7 +24,8 @@ description: - This module allows the user to create and delete a BootVolumeAttachment resource in Oracle Cloud Infrastructure - For I(state=present), attaches the specified boot volume to the specified instance. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: boot_volume_id: description: @@ -70,10 +71,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -216,33 +213,37 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "availability_domain", "compartment_id", ] - optional_list_method_params = [ - "instance_id", - "boot_volume_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["instance_id", "boot_volume_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_boot_volume_attachments, **kwargs ) diff --git a/plugins/modules/oci_compute_boot_volume_attachment_facts.py b/plugins/modules/oci_compute_boot_volume_attachment_facts.py index 97407f3004..1bac2498e7 100644 --- a/plugins/modules/oci_compute_boot_volume_attachment_facts.py +++ b/plugins/modules/oci_compute_boot_volume_attachment_facts.py @@ -53,10 +53,7 @@ description: - The OCID of the boot volume. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_compute_dedicated_vm_host.py b/plugins/modules/oci_compute_dedicated_vm_host.py index e057596251..960dfd9abe 100644 --- a/plugins/modules/oci_compute_dedicated_vm_host.py +++ b/plugins/modules/oci_compute_dedicated_vm_host.py @@ -27,7 +27,8 @@ Dedicated virtual machine hosts enable you to run your Compute virtual machine (VM) instances on dedicated servers that are a single tenant and not shared with other customers. For more information, see L(Dedicated Virtual Machine Hosts,https://docs.cloud.oracle.com/iaas/Content/Compute/Concepts/dedicatedvmhosts.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -95,10 +96,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -291,32 +288,36 @@ def get_resource(self): dedicated_vm_host_id=self.module.params.get("dedicated_vm_host_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "availability_domain", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["availability_domain", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_dedicated_vm_hosts, **kwargs ) diff --git a/plugins/modules/oci_compute_dedicated_vm_host_facts.py b/plugins/modules/oci_compute_dedicated_vm_host_facts.py index 1bec1e7ce0..f063b6dc88 100644 --- a/plugins/modules/oci_compute_dedicated_vm_host_facts.py +++ b/plugins/modules/oci_compute_dedicated_vm_host_facts.py @@ -86,10 +86,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_dedicated_vm_host_instance_facts.py b/plugins/modules/oci_compute_dedicated_vm_host_instance_facts.py index e5fce03ad4..ad0a07aa4d 100644 --- a/plugins/modules/oci_compute_dedicated_vm_host_instance_facts.py +++ b/plugins/modules/oci_compute_dedicated_vm_host_instance_facts.py @@ -62,10 +62,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_dedicated_vm_host_instance_shape_facts.py b/plugins/modules/oci_compute_dedicated_vm_host_instance_shape_facts.py new file mode 100644 index 0000000000..efc8f26ce8 --- /dev/null +++ b/plugins/modules/oci_compute_dedicated_vm_host_instance_shape_facts.py @@ -0,0 +1,167 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_compute_dedicated_vm_host_instance_shape_facts +short_description: Fetches details about one or multiple DedicatedVmHostInstanceShape resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple DedicatedVmHostInstanceShape resources in Oracle Cloud Infrastructure + - Lists the shapes that can be used to launch a virtual machine instance on a dedicated virtual machine host within the specified compartment. + You can filter the list by compatibility with a specific dedicated virtual machine host shape. +version_added: "2.5" +options: + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. + type: str + required: true + availability_domain: + description: + - The name of the availability domain. + - "Example: `Uocm:PHX-AD-1`" + type: str + dedicated_vm_host_shape: + description: + - Dedicated VM host shape name + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List dedicated_vm_host_instance_shapes + oci_compute_dedicated_vm_host_instance_shape_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +dedicated_vm_host_instance_shapes: + description: + - List of DedicatedVmHostInstanceShape resources + returned: on success + type: complex + contains: + availability_domain: + description: + - The shape's availability domain. + returned: on success + type: string + sample: Uocm:PHX-AD-1 + instance_shape_name: + description: + - The name of the virtual machine instance shapes that can be launched on a dedicated VM host. + returned: on success + type: string + sample: instance_shape_name_example + sample: [{ + "availability_domain": "Uocm:PHX-AD-1", + "instance_shape_name": "instance_shape_name_example" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import ComputeClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class DedicatedVmHostInstanceShapeFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: list""" + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def list_resources(self): + optional_list_method_params = [ + "availability_domain", + "dedicated_vm_host_shape", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_dedicated_vm_host_instance_shapes, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +DedicatedVmHostInstanceShapeFactsHelperCustom = get_custom_class( + "DedicatedVmHostInstanceShapeFactsHelperCustom" +) + + +class ResourceFactsHelper( + DedicatedVmHostInstanceShapeFactsHelperCustom, + DedicatedVmHostInstanceShapeFactsHelperGen, +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + compartment_id=dict(type="str", required=True), + availability_domain=dict(type="str"), + dedicated_vm_host_shape=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="dedicated_vm_host_instance_shape", + service_client_class=ComputeClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(dedicated_vm_host_instance_shapes=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_compute_dedicated_vm_host_shape_facts.py b/plugins/modules/oci_compute_dedicated_vm_host_shape_facts.py new file mode 100644 index 0000000000..b6dd4e888c --- /dev/null +++ b/plugins/modules/oci_compute_dedicated_vm_host_shape_facts.py @@ -0,0 +1,166 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_compute_dedicated_vm_host_shape_facts +short_description: Fetches details about one or multiple DedicatedVmHostShape resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple DedicatedVmHostShape resources in Oracle Cloud Infrastructure + - Lists the shapes that can be used to launch a dedicated virtual machine host within the specified compartment. +version_added: "2.5" +options: + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. + type: str + required: true + availability_domain: + description: + - The name of the availability domain. + - "Example: `Uocm:PHX-AD-1`" + type: str + instance_shape_name: + description: + - The name for the instance's shape. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List dedicated_vm_host_shapes + oci_compute_dedicated_vm_host_shape_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +dedicated_vm_host_shapes: + description: + - List of DedicatedVmHostShape resources + returned: on success + type: complex + contains: + availability_domain: + description: + - The shape's availability domain. + returned: on success + type: string + sample: Uocm:PHX-AD-1 + dedicated_vm_host_shape: + description: + - The name of the dedicated vm host shape. You can enumerate all available shapes by calling + L(ListDedicatedVmHostShapes,https://docs.cloud.oracle.com/#/en/iaas/20160918/dedicatedVmHostShapes). + returned: on success + type: string + sample: dedicated_vm_host_shape_example + sample: [{ + "availability_domain": "Uocm:PHX-AD-1", + "dedicated_vm_host_shape": "dedicated_vm_host_shape_example" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import ComputeClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class DedicatedVmHostShapeFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: list""" + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def list_resources(self): + optional_list_method_params = [ + "availability_domain", + "instance_shape_name", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_dedicated_vm_host_shapes, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +DedicatedVmHostShapeFactsHelperCustom = get_custom_class( + "DedicatedVmHostShapeFactsHelperCustom" +) + + +class ResourceFactsHelper( + DedicatedVmHostShapeFactsHelperCustom, DedicatedVmHostShapeFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + compartment_id=dict(type="str", required=True), + availability_domain=dict(type="str"), + instance_shape_name=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="dedicated_vm_host_shape", + service_client_class=ComputeClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(dedicated_vm_host_shapes=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_compute_device_facts.py b/plugins/modules/oci_compute_device_facts.py index 03e0b09f73..192e884e8d 100644 --- a/plugins/modules/oci_compute_device_facts.py +++ b/plugins/modules/oci_compute_device_facts.py @@ -60,10 +60,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_image.py b/plugins/modules/oci_compute_image.py index 66a539f746..efe501a63e 100644 --- a/plugins/modules/oci_compute_image.py +++ b/plugins/modules/oci_compute_image.py @@ -43,7 +43,8 @@ It does not have to be unique, and you can change it. See L(UpdateImage,https://docs.cloud.oracle.com/#/en/iaas/20160918/Image/UpdateImage). Avoid entering confidential information." - "This resource has the following action operations in the M(oci_image_actions) module: export." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -167,10 +168,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -478,33 +475,40 @@ def get_resource(self): self.client.get_image, image_id=self.module.params.get("image_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - "operating_system", - "operating_system_version", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ( + ["display_name"] + if self._use_name_as_identifier() + else ["display_name", "operating_system", "operating_system_version"] + ) + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_images, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_compute_image_actions.py b/plugins/modules/oci_compute_image_actions.py index 8839aa3bab..eec3017204 100644 --- a/plugins/modules/oci_compute_image_actions.py +++ b/plugins/modules/oci_compute_image_actions.py @@ -76,11 +76,9 @@ - The action to perform on the Image. type: str required: true - choices: ["export"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "export" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_compute_image_facts.py b/plugins/modules/oci_compute_image_facts.py index f7c4ba1daf..251c3ae26c 100644 --- a/plugins/modules/oci_compute_image_facts.py +++ b/plugins/modules/oci_compute_image_facts.py @@ -94,10 +94,7 @@ - "EXPORTING" - "DISABLED" - "DELETED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_image_shape_compatibility_entry.py b/plugins/modules/oci_compute_image_shape_compatibility_entry.py index d18f40d108..f6f409a285 100644 --- a/plugins/modules/oci_compute_image_shape_compatibility_entry.py +++ b/plugins/modules/oci_compute_image_shape_compatibility_entry.py @@ -23,7 +23,8 @@ short_description: Manage an ImageShapeCompatibilityEntry resource in Oracle Cloud Infrastructure description: - This module allows the user to update and delete an ImageShapeCompatibilityEntry resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: image_id: description: @@ -35,6 +36,19 @@ - Shape name. type: str required: true + ocpu_constraints: + description: + - "" + type: dict + suboptions: + min: + description: + - The minimum number of OCPUs supported for this image and shape. + type: int + max: + description: + - The maximum number of OCPUs supported for this image and shape. + type: int state: description: - The state of the ImageShapeCompatibilityEntry. @@ -44,10 +58,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -84,9 +94,31 @@ returned: on success type: string sample: shape_example + ocpu_constraints: + description: + - "" + returned: on success + type: complex + contains: + min: + description: + - The minimum number of OCPUs supported for this image and shape. + returned: on success + type: int + sample: 56 + max: + description: + - The maximum number of OCPUs supported for this image and shape. + returned: on success + type: int + sample: 56 sample: { "image_id": "ocid1.image.oc1..xxxxxxEXAMPLExxxxxx", - "shape": "shape_example" + "shape": "shape_example", + "ocpu_constraints": { + "min": 56, + "max": 56 + } } """ @@ -102,6 +134,7 @@ try: from oci.core import ComputeClient + from oci.core.models import AddImageShapeCompatibilityEntryDetails HAS_OCI_PY_SDK = True except ImportError: @@ -109,7 +142,7 @@ class ImageShapeCompatibilityEntryHelperGen(OCIResourceHelperBase): - """Supported operations: update and delete""" + """Supported operations: update, get, list and delete""" def get_module_resource_id_param(self): return "shape_name" @@ -117,6 +150,37 @@ def get_module_resource_id_param(self): def get_module_resource_id(self): return self.module.params.get("shape_name") + def get_get_fn(self): + return self.client.get_image_shape_compatibility_entry + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_image_shape_compatibility_entry, + image_id=self.module.params.get("image_id"), + shape_name=self.module.params.get("shape_name"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "image_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + return dict() + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_image_shape_compatibility_entries, **kwargs + ) + def is_update(self): if not self.module.params.get("state") == "present": return False @@ -129,13 +193,18 @@ def is_create(self): return not self.does_resource_exist() + def get_update_model_class(self): + return AddImageShapeCompatibilityEntryDetails + def update_resource(self): + update_details = self.get_update_model() return oci_wait_utils.call_and_wait( call_fn=self.client.add_image_shape_compatibility_entry, call_fn_args=(), call_fn_kwargs=dict( image_id=self.module.params.get("image_id"), shape_name=self.module.params.get("shape_name"), + add_image_shape_compatibility_entry_details=update_details, ), waiter_type=oci_wait_utils.NONE_WAITER_KEY, operation=oci_common_utils.UPDATE_OPERATION_KEY, @@ -179,6 +248,9 @@ def main(): dict( image_id=dict(type="str", required=True), shape_name=dict(type="str", required=True), + ocpu_constraints=dict( + type="dict", options=dict(min=dict(type="int"), max=dict(type="int")) + ), state=dict(type="str", default="present", choices=["present", "absent"]), ) ) diff --git a/plugins/modules/oci_compute_image_shape_compatibility_entry_facts.py b/plugins/modules/oci_compute_image_shape_compatibility_entry_facts.py new file mode 100644 index 0000000000..557b83216f --- /dev/null +++ b/plugins/modules/oci_compute_image_shape_compatibility_entry_facts.py @@ -0,0 +1,196 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_compute_image_shape_compatibility_entry_facts +short_description: Fetches details about one or multiple ImageShapeCompatibilityEntry resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple ImageShapeCompatibilityEntry resources in Oracle Cloud Infrastructure + - Lists the shape compatibilities for the image. + - If I(shape_name) is specified, the details of a single ImageShapeCompatibilityEntry will be returned. +version_added: "2.5" +options: + image_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the image. + type: str + required: true + shape_name: + description: + - Shape name. + - Required to get a specific image_shape_compatibility_entry. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List image_shape_compatibility_entries + oci_compute_image_shape_compatibility_entry_facts: + image_id: ocid1.image.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific image_shape_compatibility_entry + oci_compute_image_shape_compatibility_entry_facts: + image_id: ocid1.image.oc1..xxxxxxEXAMPLExxxxxx + shape_name: shape_name_example + +""" + +RETURN = """ +image_shape_compatibility_entries: + description: + - List of ImageShapeCompatibilityEntry resources + returned: on success + type: complex + contains: + image_id: + description: + - The image OCID. + returned: on success + type: string + sample: ocid1.image.oc1..xxxxxxEXAMPLExxxxxx + shape: + description: + - The shape name. + returned: on success + type: string + sample: shape_example + ocpu_constraints: + description: + - "" + returned: on success + type: complex + contains: + min: + description: + - The minimum number of OCPUs supported for this image and shape. + returned: on success + type: int + sample: 56 + max: + description: + - The maximum number of OCPUs supported for this image and shape. + returned: on success + type: int + sample: 56 + sample: [{ + "image_id": "ocid1.image.oc1..xxxxxxEXAMPLExxxxxx", + "shape": "shape_example", + "ocpu_constraints": { + "min": 56, + "max": 56 + } + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import ComputeClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ImageShapeCompatibilityEntryFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "image_id", + "shape_name", + ] + + def get_required_params_for_list(self): + return [ + "image_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_image_shape_compatibility_entry, + image_id=self.module.params.get("image_id"), + shape_name=self.module.params.get("shape_name"), + ) + + def list_resources(self): + optional_list_method_params = [] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_image_shape_compatibility_entries, + image_id=self.module.params.get("image_id"), + **optional_kwargs + ) + + +ImageShapeCompatibilityEntryFactsHelperCustom = get_custom_class( + "ImageShapeCompatibilityEntryFactsHelperCustom" +) + + +class ResourceFactsHelper( + ImageShapeCompatibilityEntryFactsHelperCustom, + ImageShapeCompatibilityEntryFactsHelperGen, +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict(image_id=dict(type="str", required=True), shape_name=dict(type="str"),) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="image_shape_compatibility_entry", + service_client_class=ComputeClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(image_shape_compatibility_entries=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_compute_instance.py b/plugins/modules/oci_compute_instance.py index 7b1971ba7c..d467503987 100644 --- a/plugins/modules/oci_compute_instance.py +++ b/plugins/modules/oci_compute_instance.py @@ -50,7 +50,8 @@ - You can later add secondary VNICs to an instance. For more information, see L(Virtual Network Interface Cards (VNICs),https://docs.cloud.oracle.com/Content/Network/Tasks/managingVNICs.htm). - "This resource has the following action operations in the M(oci_instance_actions) module: stop, start, softreset, reset, softstop." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -390,10 +391,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -933,32 +930,36 @@ def get_resource(self): self.client.get_instance, instance_id=self.module.params.get("instance_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "availability_domain", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["availability_domain", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_instances, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_compute_instance_actions.py b/plugins/modules/oci_compute_instance_actions.py index 3d9088f034..19092fe5e6 100644 --- a/plugins/modules/oci_compute_instance_actions.py +++ b/plugins/modules/oci_compute_instance_actions.py @@ -53,10 +53,7 @@ - "reset" - "softstop" required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_compute_instance_console_connection.py b/plugins/modules/oci_compute_instance_console_connection.py index 9d743ea490..3f7a68506b 100644 --- a/plugins/modules/oci_compute_instance_console_connection.py +++ b/plugins/modules/oci_compute_instance_console_connection.py @@ -27,7 +27,8 @@ After the console connection has been created and is available, you connect to the console using SSH. - For more information about console access, see L(Accessing the Console,https://docs.cloud.oracle.com/Content/Compute/References/serialconsole.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: defined_tags: description: @@ -72,10 +73,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -212,31 +209,36 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "instance_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["instance_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_instance_console_connections, **kwargs ) diff --git a/plugins/modules/oci_compute_instance_console_connection_facts.py b/plugins/modules/oci_compute_instance_console_connection_facts.py index 56972d9b2b..489b3b8087 100644 --- a/plugins/modules/oci_compute_instance_console_connection_facts.py +++ b/plugins/modules/oci_compute_instance_console_connection_facts.py @@ -43,10 +43,7 @@ description: - The OCID of the instance. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_instance_console_history.py b/plugins/modules/oci_compute_instance_console_history.py index 8770e66d5a..a3de63db0f 100644 --- a/plugins/modules/oci_compute_instance_console_history.py +++ b/plugins/modules/oci_compute_instance_console_history.py @@ -38,7 +38,8 @@ metadata). 4. Optionally, use `DeleteConsoleHistory` to delete the console history metadata and the console history data. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: defined_tags: description: @@ -88,10 +89,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -250,31 +247,36 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "instance_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["instance_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_console_histories, **kwargs ) diff --git a/plugins/modules/oci_compute_instance_console_history_content_facts.py b/plugins/modules/oci_compute_instance_console_history_content_facts.py index 1f5831853c..f69528bb80 100644 --- a/plugins/modules/oci_compute_instance_console_history_content_facts.py +++ b/plugins/modules/oci_compute_instance_console_history_content_facts.py @@ -42,10 +42,7 @@ description: - Length of the snapshot data to retrieve. type: int -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_instance_console_history_facts.py b/plugins/modules/oci_compute_instance_console_history_facts.py index bd8bd1a10e..30cdf11464 100644 --- a/plugins/modules/oci_compute_instance_console_history_facts.py +++ b/plugins/modules/oci_compute_instance_console_history_facts.py @@ -77,10 +77,7 @@ - "GETTING-HISTORY" - "SUCCEEDED" - "FAILED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_compute_instance_credentials_facts.py b/plugins/modules/oci_compute_instance_credentials_facts.py index 48db2a9bb0..93205c36a5 100644 --- a/plugins/modules/oci_compute_instance_credentials_facts.py +++ b/plugins/modules/oci_compute_instance_credentials_facts.py @@ -33,10 +33,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_instance_facts.py b/plugins/modules/oci_compute_instance_facts.py index 46fa6f9352..4ed9e87522 100644 --- a/plugins/modules/oci_compute_instance_facts.py +++ b/plugins/modules/oci_compute_instance_facts.py @@ -85,10 +85,7 @@ - "CREATING_IMAGE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_management_cluster_network.py b/plugins/modules/oci_compute_management_cluster_network.py index 3a748c914f..073c7df058 100644 --- a/plugins/modules/oci_compute_management_cluster_network.py +++ b/plugins/modules/oci_compute_management_cluster_network.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a ClusterNetwork resource in Oracle Cloud Infrastructure - For I(state=present), creates a cluster network. For more information about cluster networks, see L(Managing Cluster Networks,https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/managingclusternetworks.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -143,10 +144,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -551,31 +548,36 @@ def get_resource(self): cluster_network_id=self.module.params.get("cluster_network_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_cluster_networks, **kwargs ) diff --git a/plugins/modules/oci_compute_management_cluster_network_facts.py b/plugins/modules/oci_compute_management_cluster_network_facts.py index 0aa16b66b0..51f35f9705 100644 --- a/plugins/modules/oci_compute_management_cluster_network_facts.py +++ b/plugins/modules/oci_compute_management_cluster_network_facts.py @@ -78,10 +78,7 @@ - "STOPPED" - "TERMINATED" - "RUNNING" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_management_cluster_network_instance_facts.py b/plugins/modules/oci_compute_management_cluster_network_instance_facts.py index a3cbac7ea4..f21c9259a2 100644 --- a/plugins/modules/oci_compute_management_cluster_network_instance_facts.py +++ b/plugins/modules/oci_compute_management_cluster_network_instance_facts.py @@ -62,10 +62,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_management_instance_configuration.py b/plugins/modules/oci_compute_management_instance_configuration.py index 9187b28751..a06d1ca01f 100644 --- a/plugins/modules/oci_compute_management_instance_configuration.py +++ b/plugins/modules/oci_compute_management_instance_configuration.py @@ -26,7 +26,8 @@ - For I(state=present), creates an instance configuration. An instance configuration is a template that defines the settings to use when creating Compute instances. - "This resource has the following action operations in the M(oci_instance_configuration_actions) module: launch." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -470,10 +471,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -1134,29 +1131,23 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_instance_configurations, **kwargs ) diff --git a/plugins/modules/oci_compute_management_instance_configuration_actions.py b/plugins/modules/oci_compute_management_instance_configuration_actions.py index 9df6050f75..c3dbed0a94 100644 --- a/plugins/modules/oci_compute_management_instance_configuration_actions.py +++ b/plugins/modules/oci_compute_management_instance_configuration_actions.py @@ -411,11 +411,9 @@ - The action to perform on the InstanceConfiguration. type: str required: true - choices: ["launch"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "launch" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_management_instance_configuration_facts.py b/plugins/modules/oci_compute_management_instance_configuration_facts.py index de72bdcfa5..307d0d2e5c 100644 --- a/plugins/modules/oci_compute_management_instance_configuration_facts.py +++ b/plugins/modules/oci_compute_management_instance_configuration_facts.py @@ -59,10 +59,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_compute_management_instance_pool.py b/plugins/modules/oci_compute_management_instance_pool.py index 01d394d71f..244d8919a3 100644 --- a/plugins/modules/oci_compute_management_instance_pool.py +++ b/plugins/modules/oci_compute_management_instance_pool.py @@ -26,7 +26,8 @@ - For I(state=present), create an instance pool. - "This resource has the following action operations in the M(oci_instance_pool_actions) module: attach_load_balancer, detach_load_balancer, reset, softreset, start, stop." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -159,10 +160,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -471,31 +468,36 @@ def get_resource(self): instance_pool_id=self.module.params.get("instance_pool_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_instance_pools, **kwargs ) diff --git a/plugins/modules/oci_compute_management_instance_pool_actions.py b/plugins/modules/oci_compute_management_instance_pool_actions.py index 6b8746e5c3..ec13e2e3a6 100644 --- a/plugins/modules/oci_compute_management_instance_pool_actions.py +++ b/plugins/modules/oci_compute_management_instance_pool_actions.py @@ -67,11 +67,14 @@ - The action to perform on the InstancePool. type: str required: true - choices: ["attach_load_balancer", "detach_load_balancer", "reset", "softreset", "start", "stop"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "attach_load_balancer" + - "detach_load_balancer" + - "reset" + - "softreset" + - "start" + - "stop" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_compute_management_instance_pool_facts.py b/plugins/modules/oci_compute_management_instance_pool_facts.py index c510a2a99d..2ddf720e25 100644 --- a/plugins/modules/oci_compute_management_instance_pool_facts.py +++ b/plugins/modules/oci_compute_management_instance_pool_facts.py @@ -77,10 +77,7 @@ - "STOPPED" - "TERMINATED" - "RUNNING" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_management_instance_pool_instance_facts.py b/plugins/modules/oci_compute_management_instance_pool_instance_facts.py index e479973279..e382cbb35c 100644 --- a/plugins/modules/oci_compute_management_instance_pool_instance_facts.py +++ b/plugins/modules/oci_compute_management_instance_pool_instance_facts.py @@ -63,10 +63,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_management_instance_pool_load_balancer_attachment_facts.py b/plugins/modules/oci_compute_management_instance_pool_load_balancer_attachment_facts.py index c6eae8f6df..6b58266534 100644 --- a/plugins/modules/oci_compute_management_instance_pool_load_balancer_attachment_facts.py +++ b/plugins/modules/oci_compute_management_instance_pool_load_balancer_attachment_facts.py @@ -37,10 +37,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_shape_facts.py b/plugins/modules/oci_compute_shape_facts.py index 8a531a4775..c32dcdac2d 100644 --- a/plugins/modules/oci_compute_shape_facts.py +++ b/plugins/modules/oci_compute_shape_facts.py @@ -41,10 +41,7 @@ description: - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of an image. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_compute_vnic_attachment.py b/plugins/modules/oci_compute_vnic_attachment.py index 192effe41c..4b295c5fd7 100644 --- a/plugins/modules/oci_compute_vnic_attachment.py +++ b/plugins/modules/oci_compute_vnic_attachment.py @@ -26,7 +26,8 @@ - For I(state=present), creates a secondary VNIC and attaches it to the specified instance. For more information about secondary VNICs, see L(Virtual Network Interface Cards (VNICs),https://docs.cloud.oracle.com/Content/Network/Tasks/managingVNICs.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: create_vnic_details: description: @@ -168,10 +169,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -331,31 +328,36 @@ def get_resource(self): vnic_attachment_id=self.module.params.get("vnic_attachment_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "instance_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["instance_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_vnic_attachments, **kwargs ) diff --git a/plugins/modules/oci_compute_vnic_attachment_facts.py b/plugins/modules/oci_compute_vnic_attachment_facts.py index e19df813c9..007eaa5db6 100644 --- a/plugins/modules/oci_compute_vnic_attachment_facts.py +++ b/plugins/modules/oci_compute_vnic_attachment_facts.py @@ -53,10 +53,7 @@ description: - The OCID of the VNIC. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_compute_volume_attachment.py b/plugins/modules/oci_compute_volume_attachment.py index f6bc910649..fa80b574ec 100644 --- a/plugins/modules/oci_compute_volume_attachment.py +++ b/plugins/modules/oci_compute_volume_attachment.py @@ -24,7 +24,8 @@ description: - This module allows the user to create and delete a VolumeAttachment resource in Oracle Cloud Infrastructure - For I(state=present), attaches the specified storage volume to the specified instance. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: device: description: @@ -96,10 +97,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -324,32 +321,36 @@ def get_resource(self): volume_attachment_id=self.module.params.get("volume_attachment_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "instance_id", - "volume_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["instance_id", "volume_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_volume_attachments, **kwargs ) diff --git a/plugins/modules/oci_compute_volume_attachment_facts.py b/plugins/modules/oci_compute_volume_attachment_facts.py index b76ac84998..0c4af970f5 100644 --- a/plugins/modules/oci_compute_volume_attachment_facts.py +++ b/plugins/modules/oci_compute_volume_attachment_facts.py @@ -55,10 +55,7 @@ description: - The OCID of the volume. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_container_engine_cluster.py b/plugins/modules/oci_container_engine_cluster.py index d81f641997..3772096ec7 100644 --- a/plugins/modules/oci_container_engine_cluster.py +++ b/plugins/modules/oci_container_engine_cluster.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a Cluster resource in Oracle Cloud Infrastructure - For I(state=present), create a new cluster. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: name: description: @@ -89,6 +90,15 @@ description: - Whether or not to enable the Tiller add-on. type: bool + admission_controller_options: + description: + - Configurable cluster admission controllers + type: dict + suboptions: + is_pod_security_policy_enabled: + description: + - Whether or not to enable the Pod Security Policy admission controller. + type: bool cluster_id: description: - The OCID of the cluster. @@ -105,10 +115,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -236,6 +242,18 @@ returned: on success type: bool sample: true + admission_controller_options: + description: + - Configurable cluster admission controllers + returned: on success + type: complex + contains: + is_pod_security_policy_enabled: + description: + - Whether or not to enable the Pod Security Policy admission controller. + returned: on success + type: bool + sample: false metadata: description: - Metadata about the cluster. @@ -342,6 +360,9 @@ "add_ons": { "is_kubernetes_dashboard_enabled": true, "is_tiller_enabled": true + }, + "admission_controller_options": { + "is_pod_security_policy_enabled": false } }, "metadata": { @@ -401,31 +422,36 @@ def get_resource(self): self.client.get_cluster, cluster_id=self.module.params.get("cluster_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_clusters, **kwargs) def get_create_model_class(self): @@ -511,6 +537,10 @@ def main(): is_tiller_enabled=dict(type="bool"), ), ), + admission_controller_options=dict( + type="dict", + options=dict(is_pod_security_policy_enabled=dict(type="bool")), + ), ), ), cluster_id=dict(aliases=["id"], type="str"), diff --git a/plugins/modules/oci_container_engine_cluster_facts.py b/plugins/modules/oci_container_engine_cluster_facts.py index cbbffe7510..27f4195013 100644 --- a/plugins/modules/oci_container_engine_cluster_facts.py +++ b/plugins/modules/oci_container_engine_cluster_facts.py @@ -68,10 +68,7 @@ - "ID" - "NAME" - "TIME_CREATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -177,6 +174,18 @@ returned: on success type: bool sample: true + admission_controller_options: + description: + - Configurable cluster admission controllers + returned: on success + type: complex + contains: + is_pod_security_policy_enabled: + description: + - Whether or not to enable the Pod Security Policy admission controller. + returned: on success + type: bool + sample: false metadata: description: - Metadata about the cluster. @@ -283,6 +292,9 @@ "add_ons": { "is_kubernetes_dashboard_enabled": true, "is_tiller_enabled": true + }, + "admission_controller_options": { + "is_pod_security_policy_enabled": false } }, "metadata": { diff --git a/plugins/modules/oci_container_engine_cluster_options_facts.py b/plugins/modules/oci_container_engine_cluster_options_facts.py index dc86f5a0c0..31d9244b00 100644 --- a/plugins/modules/oci_container_engine_cluster_options_facts.py +++ b/plugins/modules/oci_container_engine_cluster_options_facts.py @@ -36,10 +36,7 @@ description: - The OCID of the compartment. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_container_engine_kubeconfig.py b/plugins/modules/oci_container_engine_kubeconfig.py index f2b2ad2137..16d76c803b 100644 --- a/plugins/modules/oci_container_engine_kubeconfig.py +++ b/plugins/modules/oci_container_engine_kubeconfig.py @@ -24,7 +24,8 @@ description: - This module allows the user to create a Kubeconfig resource in Oracle Cloud Infrastructure - For I(state=present), create the Kubeconfig YAML for a cluster. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: cluster_id: description: @@ -33,12 +34,11 @@ required: true token_version: description: - - The version of the kubeconfig token. Supported values 1.0.0 and 2.0.0 + - The version of the kubeconfig token. Supported value 2.0.0 type: str expiration: description: - - The desired expiration, in seconds, to use for the kubeconfig token. - Important Note, expiration field is only honored for token version 1.0.0 + - Deprecated. This field is no longer used. type: int state: description: @@ -48,10 +48,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -93,6 +89,13 @@ class KubeconfigHelperGen(OCIResourceHelperBase): """Supported operations: create""" + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + def get_create_model_class(self): return CreateClusterKubeconfigContentDetails diff --git a/plugins/modules/oci_container_engine_node_pool.py b/plugins/modules/oci_container_engine_node_pool.py index 7ab79a128b..e1fec1e234 100644 --- a/plugins/modules/oci_container_engine_node_pool.py +++ b/plugins/modules/oci_container_engine_node_pool.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a NodePool resource in Oracle Cloud Infrastructure - For I(state=present), create a new node pool. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -55,9 +56,28 @@ type: dict node_image_name: description: - - The name of the image running on the nodes in the node pool. - - Required for create using I(state=present). + - Deprecated. Use `nodeSourceDetails` instead. + If you specify values for both, this value is ignored. + The name of the image running on the nodes in the node pool. type: str + node_source_details: + description: + - Specify the source to use to launch nodes in the node pool. Currently, image is the only supported source. + type: dict + suboptions: + source_type: + description: + - The source type for the node. + Use `IMAGE` when specifying an OCID of an image. + type: str + choices: + - "IMAGE" + required: true + image_id: + description: + - The OCID of the image used to boot the node. + type: str + required: true node_shape: description: - The name of the node shape of the nodes in the node pool. @@ -137,10 +157,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -151,7 +167,6 @@ cluster_id: ocid1.cluster.oc1.iad.aaaaaaaaga3tombrmq3wgyrvmi3gcn3bmfsdizjwgy4wgyldmy3dcmtcmmyw name: My Node Pool kubernetes_version: v1.9.4 - node_image_name: Oracle-Linux-7.4 node_shape: VM.Standard2.4 - name: Update node_pool using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) @@ -225,16 +240,41 @@ sample: {} node_image_id: description: - - The OCID of the image running on the nodes in the node pool. + - Deprecated. see `nodeSource`. The OCID of the image running on the nodes in the node pool. returned: on success type: string sample: ocid1.image.oc1.phx.aaaaaaaanclh465xnfvajjojj5bbjzqytunslgvnyvf3fepiiltalnglekoa node_image_name: description: - - The name of the image running on the nodes in the node pool. + - Deprecated. see `nodeSource`. The name of the image running on the nodes in the node pool. returned: on success type: string sample: Oracle-Linux-7.4 + node_source: + description: + - Source running on the nodes in the node pool. + returned: on success + type: complex + contains: + source_type: + description: + - The source type of this option. + `IMAGE` means the OCID is of an image. + returned: on success + type: string + sample: IMAGE + source_name: + description: + - The user-friendly name of the entity corresponding to the OCID. + returned: on success + type: string + sample: source_name_example + image_id: + description: + - The OCID of the image. + returned: on success + type: string + sample: ocid1.image.oc1..xxxxxxEXAMPLExxxxxx node_shape: description: - The name of the node shape of the nodes in the node pool. @@ -313,6 +353,18 @@ returned: on success type: string sample: ocid1.nodepool.oc1.iad.aaaaaaaanifpelnyzmkvnepohbz4ntswkpl35syzzsugdxceth3oihe8hcfq + fault_domain: + description: + - The fault domain of this node. + returned: on success + type: string + sample: FAULT-DOMAIN-1 + private_ip: + description: + - The private IP address of this node. + returned: on success + type: string + sample: 10.0.1.1 public_ip: description: - The public IP address of this node. @@ -407,6 +459,11 @@ "node_metadata": {}, "node_image_id": "ocid1.image.oc1.phx.aaaaaaaanclh465xnfvajjojj5bbjzqytunslgvnyvf3fepiiltalnglekoa", "node_image_name": "Oracle-Linux-7.4", + "node_source": { + "source_type": "IMAGE", + "source_name": "source_name_example", + "image_id": "ocid1.image.oc1..xxxxxxEXAMPLExxxxxx" + }, "node_shape": "VM.Standard2.4", "initial_node_labels": [{ "key": "mykey", @@ -421,6 +478,8 @@ "availability_domain": "Uocm:PHX-AD-1", "subnet_id": "ocid1.subnet.oc1.iad.aaaaaaaanifpelnyzmkvnepohbz4ntswkpl35syzzsugdxceth3ofzxtlyit", "node_pool_id": "ocid1.nodepool.oc1.iad.aaaaaaaanifpelnyzmkvnepohbz4ntswkpl35syzzsugdxceth3oihe8hcfq", + "fault_domain": "FAULT-DOMAIN-1", + "private_ip": "10.0.1.1", "public_ip": "129.1.2.3", "node_error": { "code": "LimitExceeded", @@ -479,32 +538,36 @@ def get_resource(self): node_pool_id=self.module.params.get("node_pool_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "cluster_id", - "name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["cluster_id", "name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_node_pools, **kwargs ) @@ -576,6 +639,13 @@ def main(): kubernetes_version=dict(type="str"), node_metadata=dict(type="dict"), node_image_name=dict(type="str"), + node_source_details=dict( + type="dict", + options=dict( + source_type=dict(type="str", required=True, choices=["IMAGE"]), + image_id=dict(type="str", required=True), + ), + ), node_shape=dict(type="str"), initial_node_labels=dict( type="list", diff --git a/plugins/modules/oci_container_engine_node_pool_facts.py b/plugins/modules/oci_container_engine_node_pool_facts.py index 9c3bd26898..5288aec199 100644 --- a/plugins/modules/oci_container_engine_node_pool_facts.py +++ b/plugins/modules/oci_container_engine_node_pool_facts.py @@ -61,10 +61,7 @@ - "ID" - "NAME" - "TIME_CREATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -124,16 +121,41 @@ sample: {} node_image_id: description: - - The OCID of the image running on the nodes in the node pool. + - Deprecated. see `nodeSource`. The OCID of the image running on the nodes in the node pool. returned: on success type: string sample: ocid1.image.oc1.phx.aaaaaaaanclh465xnfvajjojj5bbjzqytunslgvnyvf3fepiiltalnglekoa node_image_name: description: - - The name of the image running on the nodes in the node pool. + - Deprecated. see `nodeSource`. The name of the image running on the nodes in the node pool. returned: on success type: string sample: Oracle-Linux-7.4 + node_source: + description: + - Source running on the nodes in the node pool. + returned: on success + type: complex + contains: + source_type: + description: + - The source type of this option. + `IMAGE` means the OCID is of an image. + returned: on success + type: string + sample: IMAGE + source_name: + description: + - The user-friendly name of the entity corresponding to the OCID. + returned: on success + type: string + sample: source_name_example + image_id: + description: + - The OCID of the image. + returned: on success + type: string + sample: ocid1.image.oc1..xxxxxxEXAMPLExxxxxx node_shape: description: - The name of the node shape of the nodes in the node pool. @@ -212,6 +234,18 @@ returned: on success type: string sample: ocid1.nodepool.oc1.iad.aaaaaaaanifpelnyzmkvnepohbz4ntswkpl35syzzsugdxceth3oihe8hcfq + fault_domain: + description: + - The fault domain of this node. + returned: on success + type: string + sample: FAULT-DOMAIN-1 + private_ip: + description: + - The private IP address of this node. + returned: on success + type: string + sample: 10.0.1.1 public_ip: description: - The public IP address of this node. @@ -306,6 +340,11 @@ "node_metadata": {}, "node_image_id": "ocid1.image.oc1.phx.aaaaaaaanclh465xnfvajjojj5bbjzqytunslgvnyvf3fepiiltalnglekoa", "node_image_name": "Oracle-Linux-7.4", + "node_source": { + "source_type": "IMAGE", + "source_name": "source_name_example", + "image_id": "ocid1.image.oc1..xxxxxxEXAMPLExxxxxx" + }, "node_shape": "VM.Standard2.4", "initial_node_labels": [{ "key": "mykey", @@ -320,6 +359,8 @@ "availability_domain": "Uocm:PHX-AD-1", "subnet_id": "ocid1.subnet.oc1.iad.aaaaaaaanifpelnyzmkvnepohbz4ntswkpl35syzzsugdxceth3ofzxtlyit", "node_pool_id": "ocid1.nodepool.oc1.iad.aaaaaaaanifpelnyzmkvnepohbz4ntswkpl35syzzsugdxceth3oihe8hcfq", + "fault_domain": "FAULT-DOMAIN-1", + "private_ip": "10.0.1.1", "public_ip": "129.1.2.3", "node_error": { "code": "LimitExceeded", diff --git a/plugins/modules/oci_container_engine_node_pool_options_facts.py b/plugins/modules/oci_container_engine_node_pool_options_facts.py index 00ffa012ed..7e2dda2207 100644 --- a/plugins/modules/oci_container_engine_node_pool_options_facts.py +++ b/plugins/modules/oci_container_engine_node_pool_options_facts.py @@ -36,10 +36,7 @@ description: - The OCID of the compartment. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -75,14 +72,46 @@ sample: [] images: description: - - Available image names. + - Deprecated. See sources. + When creating a node pool using the `CreateNodePoolDetails` object, only image names contained in this + property can be passed to the `nodeImageName` property. returned: on success type: list sample: [] + sources: + description: + - Available source of the node. + returned: on success + type: complex + contains: + source_type: + description: + - The source type of this option. + `IMAGE` means the OCID is of an image. + returned: on success + type: string + sample: IMAGE + source_name: + description: + - The user-friendly name of the entity corresponding to the OCID. + returned: on success + type: string + sample: source_name_example + image_id: + description: + - The OCID of the image. + returned: on success + type: string + sample: ocid1.image.oc1..xxxxxxEXAMPLExxxxxx sample: { "kubernetes_versions": [], "shapes": [], - "images": [] + "images": [], + "sources": [{ + "source_type": "IMAGE", + "source_name": "source_name_example", + "image_id": "ocid1.image.oc1..xxxxxxEXAMPLExxxxxx" + }] } """ diff --git a/plugins/modules/oci_database_autonomous_container_database.py b/plugins/modules/oci_database_autonomous_container_database.py index 398328ec75..e662364723 100644 --- a/plugins/modules/oci_database_autonomous_container_database.py +++ b/plugins/modules/oci_database_autonomous_container_database.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete an AutonomousContainerDatabase resource in Oracle Cloud Infrastructure - For I(state=present), create a new Autonomous Container Database in the specified Autonomous Exadata Infrastructure. - "This resource has the following action operations in the M(oci_autonomous_container_database_actions) module: restart." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: display_name: description: @@ -101,10 +102,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -278,6 +275,7 @@ ) try: + from oci.work_requests import WorkRequestClient from oci.database import DatabaseClient from oci.database.models import CreateAutonomousContainerDatabaseDetails from oci.database.models import UpdateAutonomousContainerDatabaseDetails @@ -290,6 +288,12 @@ class AutonomousContainerDatabaseHelperGen(OCIResourceHelperBase): """Supported operations: create, update, get, list and delete""" + def __init__(self, *args, **kwargs): + super(AutonomousContainerDatabaseHelperGen, self).__init__(*args, **kwargs) + self.work_request_client = WorkRequestClient( + self.client._config, **self.client._kwargs + ) + def get_module_resource_id_param(self): return "autonomous_container_database_id" @@ -307,32 +311,39 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): optional_list_method_params = [ "autonomous_exadata_infrastructure_id", "display_name", ] - required_kwargs = dict( - (param, self.module.params[param]) for param in required_list_method_params - ) - - optional_kwargs = dict( + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_autonomous_container_databases, **kwargs ) @@ -348,11 +359,11 @@ def create_resource(self): call_fn_kwargs=dict( create_autonomous_container_database_details=create_details, ), - waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, operation=oci_common_utils.CREATE_OPERATION_KEY, - waiter_client=self.client, + waiter_client=self.work_request_client, resource_helper=self, - wait_for_states=self.get_resource_active_states(), + wait_for_states=oci_common_utils.get_work_request_completed_states(), ) def get_update_model_class(self): @@ -369,11 +380,11 @@ def update_resource(self): ), update_autonomous_container_database_details=update_details, ), - waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, operation=oci_common_utils.UPDATE_OPERATION_KEY, - waiter_client=self.client, + waiter_client=self.work_request_client, resource_helper=self, - wait_for_states=self.get_resource_active_states(), + wait_for_states=oci_common_utils.get_work_request_completed_states(), ) def delete_resource(self): @@ -385,11 +396,11 @@ def delete_resource(self): "autonomous_container_database_id" ), ), - waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, operation=oci_common_utils.DELETE_OPERATION_KEY, - waiter_client=self.client, + waiter_client=self.work_request_client, resource_helper=self, - wait_for_states=self.get_resource_terminated_states(), + wait_for_states=oci_common_utils.get_work_request_completed_states(), ) diff --git a/plugins/modules/oci_database_autonomous_container_database_actions.py b/plugins/modules/oci_database_autonomous_container_database_actions.py index dfa9bab609..035eafd24a 100644 --- a/plugins/modules/oci_database_autonomous_container_database_actions.py +++ b/plugins/modules/oci_database_autonomous_container_database_actions.py @@ -37,11 +37,9 @@ - The action to perform on the AutonomousContainerDatabase. type: str required: true - choices: ["restart"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "restart" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ @@ -194,6 +192,7 @@ ) try: + from oci.work_requests import WorkRequestClient from oci.database import DatabaseClient HAS_OCI_PY_SDK = True @@ -207,6 +206,14 @@ class AutonomousContainerDatabaseActionsHelperGen(OCIActionsHelperBase): restart """ + def __init__(self, *args, **kwargs): + super(AutonomousContainerDatabaseActionsHelperGen, self).__init__( + *args, **kwargs + ) + self.work_request_client = WorkRequestClient( + self.client._config, **self.client._kwargs + ) + @staticmethod def get_module_resource_id_param(): return "autonomous_container_database_id" @@ -234,16 +241,14 @@ def restart(self): "autonomous_container_database_id" ), ), - waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, operation="{0}_{1}".format( self.module.params.get("action").upper(), oci_common_utils.ACTION_OPERATION_KEY, ), - waiter_client=self.client, + waiter_client=self.work_request_client, resource_helper=self, - wait_for_states=self.get_action_desired_states( - self.module.params.get("action") - ), + wait_for_states=oci_common_utils.get_work_request_completed_states(), ) diff --git a/plugins/modules/oci_database_autonomous_container_database_facts.py b/plugins/modules/oci_database_autonomous_container_database_facts.py index aa3659455d..dc37874402 100644 --- a/plugins/modules/oci_database_autonomous_container_database_facts.py +++ b/plugins/modules/oci_database_autonomous_container_database_facts.py @@ -83,10 +83,7 @@ - A filter to return only resources that match the entire display name given. The match is not case sensitive. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_database.py b/plugins/modules/oci_database_autonomous_database.py index 87bf87a3bd..99c08ae434 100644 --- a/plugins/modules/oci_database_autonomous_database.py +++ b/plugins/modules/oci_database_autonomous_database.py @@ -26,7 +26,8 @@ - For I(state=present), creates a new Autonomous Database. - "This resource has the following action operations in the M(oci_autonomous_database_actions) module: deregister_autonomous_database_data_safe, generate_autonomous_database_wallet, register_autonomous_database_data_safe, restart, restore, start, stop." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -214,10 +215,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -656,35 +653,46 @@ def get_resource(self): autonomous_database_id=self.module.params.get("autonomous_database_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "autonomous_container_database_id", - "db_workload", - "db_version", - "is_free_tier", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ( + ["autonomous_container_database_id", "db_workload", "display_name"] + if self._use_name_as_identifier() + else [ + "autonomous_container_database_id", + "db_workload", + "db_version", + "is_free_tier", + "display_name", + ] + ) + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_autonomous_databases, **kwargs ) @@ -758,7 +766,7 @@ def main(): db_workload=dict(type="str", choices=["OLTP", "DW"]), data_storage_size_in_tbs=dict(type="int"), is_free_tier=dict(type="bool"), - admin_password=dict(type="str"), + admin_password=dict(type="str", no_log=True), display_name=dict(aliases=["name"], type="str"), license_model=dict( type="str", choices=["LICENSE_INCLUDED", "BRING_YOUR_OWN_LICENSE"] diff --git a/plugins/modules/oci_database_autonomous_database_actions.py b/plugins/modules/oci_database_autonomous_database_actions.py index 74ee630e47..b626895cb8 100644 --- a/plugins/modules/oci_database_autonomous_database_actions.py +++ b/plugins/modules/oci_database_autonomous_database_actions.py @@ -84,12 +84,15 @@ - The action to perform on the AutonomousDatabase. type: str required: true - choices: ["deregister_autonomous_database_data_safe", "generate_autonomous_database_wallet", - "register_autonomous_database_data_safe", "restart", "restore", "start", "stop"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "deregister_autonomous_database_data_safe" + - "generate_autonomous_database_wallet" + - "register_autonomous_database_data_safe" + - "restart" + - "restore" + - "start" + - "stop" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_database_autonomous_database_backup.py b/plugins/modules/oci_database_autonomous_database_backup.py index 0446a182ab..137c6feef3 100644 --- a/plugins/modules/oci_database_autonomous_database_backup.py +++ b/plugins/modules/oci_database_autonomous_database_backup.py @@ -24,7 +24,8 @@ description: - This module allows the user to create an AutonomousDatabaseBackup resource in Oracle Cloud Infrastructure - For I(state=present), creates a new Autonomous Database backup for the specified database based on the provided request parameters. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: display_name: description: @@ -45,10 +46,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -195,30 +192,30 @@ def get_resource(self): ), ) - def list_resources(self): - required_list_method_params = [] - - optional_list_method_params = [ - "autonomous_database_id", - "display_name", - ] + def get_required_kwargs_for_list(self): + return dict() - required_kwargs = dict( - (param, self.module.params[param]) for param in required_list_method_params - ) + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["autonomous_database_id", "display_name"] - optional_kwargs = dict( + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_autonomous_database_backups, **kwargs ) diff --git a/plugins/modules/oci_database_autonomous_database_backup_facts.py b/plugins/modules/oci_database_autonomous_database_backup_facts.py index 46167b4332..652af38536 100644 --- a/plugins/modules/oci_database_autonomous_database_backup_facts.py +++ b/plugins/modules/oci_database_autonomous_database_backup_facts.py @@ -72,10 +72,7 @@ - A filter to return only resources that match the entire display name given. The match is not case sensitive. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_database_facts.py b/plugins/modules/oci_database_autonomous_database_facts.py index 8f8c189767..d9f38cfb07 100644 --- a/plugins/modules/oci_database_autonomous_database_facts.py +++ b/plugins/modules/oci_database_autonomous_database_facts.py @@ -101,10 +101,7 @@ - A filter to return only resources that match the entire display name given. The match is not case sensitive. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_database_regional_wallet.py b/plugins/modules/oci_database_autonomous_database_regional_wallet.py index a71704b5bd..e0e6c5db7e 100644 --- a/plugins/modules/oci_database_autonomous_database_regional_wallet.py +++ b/plugins/modules/oci_database_autonomous_database_regional_wallet.py @@ -23,7 +23,8 @@ short_description: Manage an AutonomousDatabaseRegionalWallet resource in Oracle Cloud Infrastructure description: - This module allows the user to update an AutonomousDatabaseRegionalWallet resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: should_rotate: description: @@ -37,10 +38,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_database_autonomous_database_regional_wallet_facts.py b/plugins/modules/oci_database_autonomous_database_regional_wallet_facts.py index f9e6ae9d33..6ae825ca8a 100644 --- a/plugins/modules/oci_database_autonomous_database_regional_wallet_facts.py +++ b/plugins/modules/oci_database_autonomous_database_regional_wallet_facts.py @@ -26,10 +26,7 @@ - Gets the Autonomous Database regional wallet details. version_added: "2.5" options: {} -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_database_wallet.py b/plugins/modules/oci_database_autonomous_database_wallet.py index 99864e0df5..9c01b995f0 100644 --- a/plugins/modules/oci_database_autonomous_database_wallet.py +++ b/plugins/modules/oci_database_autonomous_database_wallet.py @@ -23,7 +23,8 @@ short_description: Manage an AutonomousDatabaseWallet resource in Oracle Cloud Infrastructure description: - This module allows the user to update an AutonomousDatabaseWallet resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: autonomous_database_id: description: @@ -43,10 +44,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_database_autonomous_database_wallet_facts.py b/plugins/modules/oci_database_autonomous_database_wallet_facts.py index 87edb7306c..d49c616dc3 100644 --- a/plugins/modules/oci_database_autonomous_database_wallet_facts.py +++ b/plugins/modules/oci_database_autonomous_database_wallet_facts.py @@ -32,10 +32,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_db_preview_version_facts.py b/plugins/modules/oci_database_autonomous_db_preview_version_facts.py index 91088f7a4e..b6009c2e49 100644 --- a/plugins/modules/oci_database_autonomous_db_preview_version_facts.py +++ b/plugins/modules/oci_database_autonomous_db_preview_version_facts.py @@ -46,10 +46,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_db_version_facts.py b/plugins/modules/oci_database_autonomous_db_version_facts.py index fef4b816ce..8b4e583a05 100644 --- a/plugins/modules/oci_database_autonomous_db_version_facts.py +++ b/plugins/modules/oci_database_autonomous_db_version_facts.py @@ -45,10 +45,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_exadata_infrastructure.py b/plugins/modules/oci_database_autonomous_exadata_infrastructure.py index 9cfd540f12..add9509abf 100644 --- a/plugins/modules/oci_database_autonomous_exadata_infrastructure.py +++ b/plugins/modules/oci_database_autonomous_exadata_infrastructure.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete an AutonomousExadataInfrastructure resource in Oracle Cloud Infrastructure - For I(state=present), launches a new Autonomous Exadata Infrastructure in the specified compartment and availability domain. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -171,10 +172,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -419,6 +416,7 @@ ) try: + from oci.work_requests import WorkRequestClient from oci.database import DatabaseClient from oci.database.models import LaunchAutonomousExadataInfrastructureDetails from oci.database.models import UpdateAutonomousExadataInfrastructureDetails @@ -431,6 +429,12 @@ class AutonomousExadataInfrastructureHelperGen(OCIResourceHelperBase): """Supported operations: create, update, get, list and delete""" + def __init__(self, *args, **kwargs): + super(AutonomousExadataInfrastructureHelperGen, self).__init__(*args, **kwargs) + self.work_request_client = WorkRequestClient( + self.client._config, **self.client._kwargs + ) + def get_module_resource_id_param(self): return "autonomous_exadata_infrastructure_id" @@ -448,32 +452,36 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "availability_domain", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["availability_domain", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_autonomous_exadata_infrastructures, **kwargs ) @@ -489,11 +497,11 @@ def create_resource(self): call_fn_kwargs=dict( launch_autonomous_exadata_infrastructure_details=create_details, ), - waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, operation=oci_common_utils.CREATE_OPERATION_KEY, - waiter_client=self.client, + waiter_client=self.work_request_client, resource_helper=self, - wait_for_states=self.get_resource_active_states(), + wait_for_states=oci_common_utils.get_work_request_completed_states(), ) def get_update_model_class(self): @@ -510,11 +518,11 @@ def update_resource(self): ), update_autonomous_exadata_infrastructures_details=update_details, ), - waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, operation=oci_common_utils.UPDATE_OPERATION_KEY, - waiter_client=self.client, + waiter_client=self.work_request_client, resource_helper=self, - wait_for_states=self.get_resource_active_states(), + wait_for_states=oci_common_utils.get_work_request_completed_states(), ) def delete_resource(self): @@ -526,11 +534,11 @@ def delete_resource(self): "autonomous_exadata_infrastructure_id" ), ), - waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, operation=oci_common_utils.DELETE_OPERATION_KEY, - waiter_client=self.client, + waiter_client=self.work_request_client, resource_helper=self, - wait_for_states=self.get_resource_terminated_states(), + wait_for_states=oci_common_utils.get_work_request_completed_states(), ) diff --git a/plugins/modules/oci_database_autonomous_exadata_infrastructure_facts.py b/plugins/modules/oci_database_autonomous_exadata_infrastructure_facts.py index ecac108762..409ce77a89 100644 --- a/plugins/modules/oci_database_autonomous_exadata_infrastructure_facts.py +++ b/plugins/modules/oci_database_autonomous_exadata_infrastructure_facts.py @@ -75,10 +75,7 @@ - A filter to return only resources that match the entire display name given. The match is not case sensitive. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_autonomous_exadata_infrastructure_shape_facts.py b/plugins/modules/oci_database_autonomous_exadata_infrastructure_shape_facts.py index daf719ab9d..78d9f399ac 100644 --- a/plugins/modules/oci_database_autonomous_exadata_infrastructure_shape_facts.py +++ b/plugins/modules/oci_database_autonomous_exadata_infrastructure_shape_facts.py @@ -37,10 +37,7 @@ - The compartment L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_database_backup.py b/plugins/modules/oci_database_backup.py index 486e87038a..31b9e1cc8d 100644 --- a/plugins/modules/oci_database_backup.py +++ b/plugins/modules/oci_database_backup.py @@ -26,7 +26,8 @@ - For I(state=present), creates a new backup in the specified database based on the request parameters you provide. If you previously used RMAN or dbcli to configure backups and then you switch to using the Console or the API for backups, a new backup configuration is created and associated with your database. This means that you can no longer rely on your previously configured unmanaged backups to work. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: database_id: description: @@ -60,10 +61,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -224,30 +221,30 @@ def get_resource(self): self.client.get_backup, backup_id=self.module.params.get("backup_id"), ) - def list_resources(self): - required_list_method_params = [] - - optional_list_method_params = [ - "database_id", - "compartment_id", - ] + def get_required_kwargs_for_list(self): + return dict() - required_kwargs = dict( - (param, self.module.params[param]) for param in required_list_method_params - ) + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["database_id", "compartment_id"] - optional_kwargs = dict( + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_backups, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_database_backup_facts.py b/plugins/modules/oci_database_backup_facts.py index 6db5e4382b..a06abd45ae 100644 --- a/plugins/modules/oci_database_backup_facts.py +++ b/plugins/modules/oci_database_backup_facts.py @@ -41,10 +41,7 @@ description: - The compartment L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_database_data_guard_association.py b/plugins/modules/oci_database_data_guard_association.py new file mode 100644 index 0000000000..93b37b0ef0 --- /dev/null +++ b/plugins/modules/oci_database_data_guard_association.py @@ -0,0 +1,440 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_database_data_guard_association +short_description: Manage a DataGuardAssociation resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create a DataGuardAssociation resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new Data Guard association. A Data Guard association represents the replication relationship between the + specified database and a peer database. For more information, see L(Using Oracle Data + Guard,https://docs.cloud.oracle.com/Content/Database/Tasks/usingdataguard.htm). + - All Oracle Cloud Infrastructure resources, including Data Guard associations, get an Oracle-assigned, unique ID + called an Oracle Cloud Identifier (OCID). When you create a resource, you can find its OCID in the response. + You can also retrieve a resource's OCID by using a List API operation on that resource type, or by viewing the + resource in the Console. For more information, see + L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). + - "This resource has the following action operations in the M(oci_data_guard_association_actions) module: failover, reinstate, switchover." +version_added: "2.9" +author: Oracle (@oracle) +options: + database_id: + description: + - The database L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). + type: str + required: true + database_admin_password: + description: + - A strong password for the `SYS`, `SYSTEM`, and `PDB Admin` users to apply during standby creation. + - "The password must contain no fewer than nine characters and include:" + - "* At least two uppercase characters." + - "* At least two lowercase characters." + - "* At least two numeric characters." + - "* At least two special characters. Valid special characters include \\"_\\", \\"#\\", and \\"-\\" only." + - "**The password MUST be the same as the primary admin password.**" + type: str + required: true + protection_mode: + description: + - The protection mode to set up between the primary and standby databases. For more information, see + L(Oracle Data Guard Protection Modes,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-protection-modes.htm#SBYDB02000) + in the Oracle Data Guard documentation. + - "**IMPORTANT** - The only protection mode currently supported by the Database service is MAXIMUM_PERFORMANCE." + type: str + choices: + - "MAXIMUM_AVAILABILITY" + - "MAXIMUM_PERFORMANCE" + - "MAXIMUM_PROTECTION" + required: true + transport_type: + description: + - "The redo transport type to use for this Data Guard association. Valid values depend on the specified `protectionMode`:" + - "* MAXIMUM_AVAILABILITY - SYNC or FASTSYNC + * MAXIMUM_PERFORMANCE - ASYNC + * MAXIMUM_PROTECTION - SYNC" + - For more information, see + L(Redo Transport Services,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-redo-transport-services.htm#SBYDB00400) + in the Oracle Data Guard documentation. + - "**IMPORTANT** - The only transport type currently supported by the Database service is ASYNC." + type: str + choices: + - "SYNC" + - "ASYNC" + - "FASTSYNC" + required: true + creation_type: + description: + - Specifies whether to create the peer database in an existing DB system or in a new DB system. + type: str + choices: + - "NewDbSystem" + - "ExistingDbSystem" + required: true + display_name: + description: + - The user-friendly name of the DB system that will contain the the standby database. The display name does not have to be unique. + - Applicable when creation_type is 'NewDbSystem' + type: str + aliases: ["name"] + availability_domain: + description: + - "The name of the availability domain that the standby database DB system will be located in. For example- \\"Uocm:PHX-AD-1\\"." + - Applicable when creation_type is 'NewDbSystem' + type: str + shape: + description: + - The virtual machine DB system shape to launch for the standby database in the Data Guard association. The shape determines the number of CPU cores + and the amount of memory available for the DB system. + Only virtual machine shapes are valid options. If you do not supply this parameter, the default shape is the shape of the primary DB system. + - To get a list of all shapes, use the + L(ListDbSystemShapes,https://docs.cloud.oracle.com/#/en/database/20160918/DbSystemShapeSummary/ListDbSystemShapes) operation. + - Applicable when creation_type is 'NewDbSystem' + type: str + subnet_id: + description: + - "The OCID of the subnet the DB system is associated with. + **Subnet Restrictions:** + - For 1- and 2-node RAC DB systems, do not use a subnet that overlaps with 192.168.16.16/28" + - These subnets are used by the Oracle Clusterware private interconnect on the database instance. + Specifying an overlapping subnet will cause the private interconnect to malfunction. + This restriction applies to both the client subnet and backup subnet. + - Applicable when creation_type is 'NewDbSystem' + type: str + nsg_ids: + description: + - "A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that this + resource belongs to. Setting this to an empty array after the list is created removes the resource from all NSGs. For more information about NSGs, + see L(Security Rules,https://docs.cloud.oracle.com/Content/Network/Concepts/securityrules.htm). + **NsgIds restrictions:** + - Autonomous Databases with private access require at least 1 Network Security Group (NSG). The nsgIds array cannot be empty." + - Applicable when creation_type is 'NewDbSystem' + type: list + backup_network_nsg_ids: + description: + - A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that the + backup network of this DB system belongs to. Setting this to an empty array after the list is created removes the resource from all NSGs. For more + information about NSGs, see L(Security Rules,https://docs.cloud.oracle.com/Content/Network/Concepts/securityrules.htm). Applicable only to Exadata + DB systems. + - Applicable when creation_type is 'NewDbSystem' + type: list + hostname: + description: + - The hostname for the DB node. + - Applicable when creation_type is 'NewDbSystem' + type: str + peer_db_system_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the DB system in which to create the standby database. + You must supply this value if creationType is `ExistingDbSystem`. + - Applicable when creation_type is 'ExistingDbSystem' + type: str + state: + description: + - The state of the DataGuardAssociation. + - Use I(state=present) to create a DataGuardAssociation. + type: str + required: false + default: 'present' + choices: ["present"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create data_guard_association + oci_database_data_guard_association: + database_id: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + database_admin_password: database_admin_password_example + protection_mode: MAXIMUM_AVAILABILITY + transport_type: SYNC + creation_type: ExistingDbSystem + +""" + +RETURN = """ +data_guard_association: + description: + - Details of the DataGuardAssociation resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the Data Guard association. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + database_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the reporting database. + returned: on success + type: string + sample: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + role: + description: + - The role of the reporting database in this Data Guard association. + returned: on success + type: string + sample: PRIMARY + lifecycle_state: + description: + - The current state of the Data Guard association. + returned: on success + type: string + sample: PROVISIONING + lifecycle_details: + description: + - Additional information about the current lifecycleState, if available. + returned: on success + type: string + sample: lifecycle_details_example + peer_db_system_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the DB system containing the associated + peer database. + returned: on success + type: string + sample: ocid1.peerdbsystem.oc1..xxxxxxEXAMPLExxxxxx + peer_db_home_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the Database Home containing the associated peer + database. + returned: on success + type: string + sample: ocid1.peerdbhome.oc1..xxxxxxEXAMPLExxxxxx + peer_database_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the associated peer database. + returned: on success + type: string + sample: ocid1.peerdatabase.oc1..xxxxxxEXAMPLExxxxxx + peer_data_guard_association_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the peer database's Data Guard association. + returned: on success + type: string + sample: ocid1.peerdataguardassociation.oc1..xxxxxxEXAMPLExxxxxx + peer_role: + description: + - The role of the peer database in this Data Guard association. + returned: on success + type: string + sample: PRIMARY + apply_lag: + description: + - The lag time between updates to the primary database and application of the redo data on the standby database, + as computed by the reporting database. + - "Example: `9 seconds`" + returned: on success + type: string + sample: 9 seconds + apply_rate: + description: + - The rate at which redo logs are synced between the associated databases. + - "Example: `180 Mb per second`" + returned: on success + type: string + sample: 180 Mb per second + protection_mode: + description: + - The protection mode of this Data Guard association. For more information, see + L(Oracle Data Guard Protection Modes,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-protection-modes.htm#SBYDB02000) + in the Oracle Data Guard documentation. + returned: on success + type: string + sample: MAXIMUM_AVAILABILITY + transport_type: + description: + - The redo transport type used by this Data Guard association. For more information, see + L(Redo Transport Services,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-redo-transport-services.htm#SBYDB00400) + in the Oracle Data Guard documentation. + returned: on success + type: string + sample: SYNC + time_created: + description: + - The date and time the Data Guard association was created. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "database_id": "ocid1.database.oc1..xxxxxxEXAMPLExxxxxx", + "role": "PRIMARY", + "lifecycle_state": "PROVISIONING", + "lifecycle_details": "lifecycle_details_example", + "peer_db_system_id": "ocid1.peerdbsystem.oc1..xxxxxxEXAMPLExxxxxx", + "peer_db_home_id": "ocid1.peerdbhome.oc1..xxxxxxEXAMPLExxxxxx", + "peer_database_id": "ocid1.peerdatabase.oc1..xxxxxxEXAMPLExxxxxx", + "peer_data_guard_association_id": "ocid1.peerdataguardassociation.oc1..xxxxxxEXAMPLExxxxxx", + "peer_role": "PRIMARY", + "apply_lag": "9 seconds", + "apply_rate": "180 Mb per second", + "protection_mode": "MAXIMUM_AVAILABILITY", + "transport_type": "SYNC", + "time_created": "2013-10-20T19:20:30+01:00" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.work_requests import WorkRequestClient + from oci.database import DatabaseClient + from oci.database.models import CreateDataGuardAssociationDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class DataGuardAssociationHelperGen(OCIResourceHelperBase): + """Supported operations: create, get and list""" + + def __init__(self, *args, **kwargs): + super(DataGuardAssociationHelperGen, self).__init__(*args, **kwargs) + self.work_request_client = WorkRequestClient( + self.client._config, **self.client._kwargs + ) + + def get_get_fn(self): + return self.client.get_data_guard_association + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_data_guard_association, + database_id=self.module.params.get("database_id"), + data_guard_association_id=self.module.params.get( + "data_guard_association_id" + ), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "database_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + return dict() + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_data_guard_associations, **kwargs + ) + + def get_create_model_class(self): + return CreateDataGuardAssociationDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_data_guard_association, + call_fn_args=(), + call_fn_kwargs=dict( + database_id=self.module.params.get("database_id"), + create_data_guard_association_details=create_details, + ), + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.work_request_client, + resource_helper=self, + wait_for_states=oci_common_utils.get_work_request_completed_states(), + ) + + +DataGuardAssociationHelperCustom = get_custom_class("DataGuardAssociationHelperCustom") + + +class ResourceHelper(DataGuardAssociationHelperCustom, DataGuardAssociationHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + database_id=dict(type="str", required=True), + database_admin_password=dict(type="str", required=True, no_log=True), + protection_mode=dict( + type="str", + required=True, + choices=[ + "MAXIMUM_AVAILABILITY", + "MAXIMUM_PERFORMANCE", + "MAXIMUM_PROTECTION", + ], + ), + transport_type=dict( + type="str", required=True, choices=["SYNC", "ASYNC", "FASTSYNC"] + ), + creation_type=dict( + type="str", required=True, choices=["NewDbSystem", "ExistingDbSystem"] + ), + display_name=dict(aliases=["name"], type="str"), + availability_domain=dict(type="str"), + shape=dict(type="str"), + subnet_id=dict(type="str"), + nsg_ids=dict(type="list"), + backup_network_nsg_ids=dict(type="list"), + hostname=dict(type="str"), + peer_db_system_id=dict(type="str"), + state=dict(type="str", default="present", choices=["present"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="data_guard_association", + service_client_class=DatabaseClient, + namespace="database", + ) + + result = dict(changed=False) + + if resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_database_data_guard_association_actions.py b/plugins/modules/oci_database_data_guard_association_actions.py new file mode 100644 index 0000000000..e26ea34620 --- /dev/null +++ b/plugins/modules/oci_database_data_guard_association_actions.py @@ -0,0 +1,388 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_database_data_guard_association_actions +short_description: Perform actions on a DataGuardAssociation resource in Oracle Cloud Infrastructure +description: + - Perform actions on a DataGuardAssociation resource in Oracle Cloud Infrastructure + - For I(action=failover), performs a failover to transition the standby database identified by the `databaseId` parameter into the + specified Data Guard association's primary role after the existing primary database fails or becomes unreachable. + A failover might result in data loss depending on the protection mode in effect at the time of the primary + database failure. + - For I(action=reinstate), reinstates the database identified by the `databaseId` parameter into the standby role in a Data Guard association. + - For I(action=switchover), performs a switchover to transition the primary database of a Data Guard association into a standby role. The + standby database associated with the `dataGuardAssociationId` assumes the primary database role. + A switchover guarantees no data loss. +version_added: "2.5" +options: + database_id: + description: + - The database L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). + type: str + required: true + data_guard_association_id: + description: + - The Data Guard association's L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). + type: str + aliases: ["id"] + required: true + database_admin_password: + description: + - The DB system administrator password. + type: str + required: true + action: + description: + - The action to perform on the DataGuardAssociation. + type: str + required: true + choices: + - "failover" + - "reinstate" + - "switchover" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Perform action failover on data_guard_association + oci_database_data_guard_association_actions: + database_id: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + data_guard_association_id: ocid1.dataguardassociation.oc1..xxxxxxEXAMPLExxxxxx + database_admin_password: database_admin_password_example + action: failover + +- name: Perform action reinstate on data_guard_association + oci_database_data_guard_association_actions: + database_id: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + data_guard_association_id: ocid1.dataguardassociation.oc1..xxxxxxEXAMPLExxxxxx + database_admin_password: database_admin_password_example + action: reinstate + +- name: Perform action switchover on data_guard_association + oci_database_data_guard_association_actions: + database_id: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + data_guard_association_id: ocid1.dataguardassociation.oc1..xxxxxxEXAMPLExxxxxx + database_admin_password: database_admin_password_example + action: switchover + +""" + +RETURN = """ +data_guard_association: + description: + - Details of the DataGuardAssociation resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the Data Guard association. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + database_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the reporting database. + returned: on success + type: string + sample: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + role: + description: + - The role of the reporting database in this Data Guard association. + returned: on success + type: string + sample: PRIMARY + lifecycle_state: + description: + - The current state of the Data Guard association. + returned: on success + type: string + sample: PROVISIONING + lifecycle_details: + description: + - Additional information about the current lifecycleState, if available. + returned: on success + type: string + sample: lifecycle_details_example + peer_db_system_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the DB system containing the associated + peer database. + returned: on success + type: string + sample: ocid1.peerdbsystem.oc1..xxxxxxEXAMPLExxxxxx + peer_db_home_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the Database Home containing the associated peer + database. + returned: on success + type: string + sample: ocid1.peerdbhome.oc1..xxxxxxEXAMPLExxxxxx + peer_database_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the associated peer database. + returned: on success + type: string + sample: ocid1.peerdatabase.oc1..xxxxxxEXAMPLExxxxxx + peer_data_guard_association_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the peer database's Data Guard association. + returned: on success + type: string + sample: ocid1.peerdataguardassociation.oc1..xxxxxxEXAMPLExxxxxx + peer_role: + description: + - The role of the peer database in this Data Guard association. + returned: on success + type: string + sample: PRIMARY + apply_lag: + description: + - The lag time between updates to the primary database and application of the redo data on the standby database, + as computed by the reporting database. + - "Example: `9 seconds`" + returned: on success + type: string + sample: 9 seconds + apply_rate: + description: + - The rate at which redo logs are synced between the associated databases. + - "Example: `180 Mb per second`" + returned: on success + type: string + sample: 180 Mb per second + protection_mode: + description: + - The protection mode of this Data Guard association. For more information, see + L(Oracle Data Guard Protection Modes,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-protection-modes.htm#SBYDB02000) + in the Oracle Data Guard documentation. + returned: on success + type: string + sample: MAXIMUM_AVAILABILITY + transport_type: + description: + - The redo transport type used by this Data Guard association. For more information, see + L(Redo Transport Services,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-redo-transport-services.htm#SBYDB00400) + in the Oracle Data Guard documentation. + returned: on success + type: string + sample: SYNC + time_created: + description: + - The date and time the Data Guard association was created. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "database_id": "ocid1.database.oc1..xxxxxxEXAMPLExxxxxx", + "role": "PRIMARY", + "lifecycle_state": "PROVISIONING", + "lifecycle_details": "lifecycle_details_example", + "peer_db_system_id": "ocid1.peerdbsystem.oc1..xxxxxxEXAMPLExxxxxx", + "peer_db_home_id": "ocid1.peerdbhome.oc1..xxxxxxEXAMPLExxxxxx", + "peer_database_id": "ocid1.peerdatabase.oc1..xxxxxxEXAMPLExxxxxx", + "peer_data_guard_association_id": "ocid1.peerdataguardassociation.oc1..xxxxxxEXAMPLExxxxxx", + "peer_role": "PRIMARY", + "apply_lag": "9 seconds", + "apply_rate": "180 Mb per second", + "protection_mode": "MAXIMUM_AVAILABILITY", + "transport_type": "SYNC", + "time_created": "2013-10-20T19:20:30+01:00" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIActionsHelperBase, + get_custom_class, +) + +try: + from oci.work_requests import WorkRequestClient + from oci.database import DatabaseClient + from oci.database.models import FailoverDataGuardAssociationDetails + from oci.database.models import ReinstateDataGuardAssociationDetails + from oci.database.models import SwitchoverDataGuardAssociationDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class DataGuardAssociationActionsHelperGen(OCIActionsHelperBase): + """ + Supported actions: + failover + reinstate + switchover + """ + + def __init__(self, *args, **kwargs): + super(DataGuardAssociationActionsHelperGen, self).__init__(*args, **kwargs) + self.work_request_client = WorkRequestClient( + self.client._config, **self.client._kwargs + ) + + @staticmethod + def get_module_resource_id_param(): + return "data_guard_association_id" + + def get_module_resource_id(self): + return self.module.params.get("data_guard_association_id") + + def get_get_fn(self): + return self.client.get_data_guard_association + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_data_guard_association, + database_id=self.module.params.get("database_id"), + data_guard_association_id=self.module.params.get( + "data_guard_association_id" + ), + ) + + def failover(self): + action_details = oci_common_utils.convert_input_data_to_model_class( + self.module.params, FailoverDataGuardAssociationDetails + ) + return oci_wait_utils.call_and_wait( + call_fn=self.client.failover_data_guard_association, + call_fn_args=(), + call_fn_kwargs=dict( + database_id=self.module.params.get("database_id"), + data_guard_association_id=self.module.params.get( + "data_guard_association_id" + ), + failover_data_guard_association_details=action_details, + ), + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.work_request_client, + resource_helper=self, + wait_for_states=oci_common_utils.get_work_request_completed_states(), + ) + + def reinstate(self): + action_details = oci_common_utils.convert_input_data_to_model_class( + self.module.params, ReinstateDataGuardAssociationDetails + ) + return oci_wait_utils.call_and_wait( + call_fn=self.client.reinstate_data_guard_association, + call_fn_args=(), + call_fn_kwargs=dict( + database_id=self.module.params.get("database_id"), + data_guard_association_id=self.module.params.get( + "data_guard_association_id" + ), + reinstate_data_guard_association_details=action_details, + ), + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.work_request_client, + resource_helper=self, + wait_for_states=oci_common_utils.get_work_request_completed_states(), + ) + + def switchover(self): + action_details = oci_common_utils.convert_input_data_to_model_class( + self.module.params, SwitchoverDataGuardAssociationDetails + ) + return oci_wait_utils.call_and_wait( + call_fn=self.client.switchover_data_guard_association, + call_fn_args=(), + call_fn_kwargs=dict( + database_id=self.module.params.get("database_id"), + data_guard_association_id=self.module.params.get( + "data_guard_association_id" + ), + switchover_data_guard_association_details=action_details, + ), + waiter_type=oci_wait_utils.WORK_REQUEST_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.work_request_client, + resource_helper=self, + wait_for_states=oci_common_utils.get_work_request_completed_states(), + ) + + +DataGuardAssociationActionsHelperCustom = get_custom_class( + "DataGuardAssociationActionsHelperCustom" +) + + +class ResourceHelper( + DataGuardAssociationActionsHelperCustom, DataGuardAssociationActionsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=True + ) + module_args.update( + dict( + database_id=dict(type="str", required=True), + data_guard_association_id=dict(aliases=["id"], type="str", required=True), + database_admin_password=dict(type="str", required=True, no_log=True), + action=dict( + type="str", + required=True, + choices=["failover", "reinstate", "switchover"], + ), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="data_guard_association", + service_client_class=DatabaseClient, + namespace="database", + ) + + result = resource_helper.perform_action(module.params.get("action")) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_database_data_guard_association_facts.py b/plugins/modules/oci_database_data_guard_association_facts.py new file mode 100644 index 0000000000..3846028b6b --- /dev/null +++ b/plugins/modules/oci_database_data_guard_association_facts.py @@ -0,0 +1,279 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_database_data_guard_association_facts +short_description: Fetches details about one or multiple DataGuardAssociation resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple DataGuardAssociation resources in Oracle Cloud Infrastructure + - Lists all Data Guard associations for the specified database. + - If I(data_guard_association_id) is specified, the details of a single DataGuardAssociation will be returned. +version_added: "2.5" +options: + database_id: + description: + - The database L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). + type: str + required: true + data_guard_association_id: + description: + - The Data Guard association's L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). + - Required to get a specific data_guard_association. + type: str + aliases: ["id"] +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List data_guard_associations + oci_database_data_guard_association_facts: + database_id: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific data_guard_association + oci_database_data_guard_association_facts: + database_id: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + data_guard_association_id: ocid1.dataguardassociation.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +data_guard_associations: + description: + - List of DataGuardAssociation resources + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the Data Guard association. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + database_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the reporting database. + returned: on success + type: string + sample: ocid1.database.oc1..xxxxxxEXAMPLExxxxxx + role: + description: + - The role of the reporting database in this Data Guard association. + returned: on success + type: string + sample: PRIMARY + lifecycle_state: + description: + - The current state of the Data Guard association. + returned: on success + type: string + sample: PROVISIONING + lifecycle_details: + description: + - Additional information about the current lifecycleState, if available. + returned: on success + type: string + sample: lifecycle_details_example + peer_db_system_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the DB system containing the associated + peer database. + returned: on success + type: string + sample: ocid1.peerdbsystem.oc1..xxxxxxEXAMPLExxxxxx + peer_db_home_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the Database Home containing the associated peer + database. + returned: on success + type: string + sample: ocid1.peerdbhome.oc1..xxxxxxEXAMPLExxxxxx + peer_database_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the associated peer database. + returned: on success + type: string + sample: ocid1.peerdatabase.oc1..xxxxxxEXAMPLExxxxxx + peer_data_guard_association_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the peer database's Data Guard association. + returned: on success + type: string + sample: ocid1.peerdataguardassociation.oc1..xxxxxxEXAMPLExxxxxx + peer_role: + description: + - The role of the peer database in this Data Guard association. + returned: on success + type: string + sample: PRIMARY + apply_lag: + description: + - The lag time between updates to the primary database and application of the redo data on the standby database, + as computed by the reporting database. + - "Example: `9 seconds`" + returned: on success + type: string + sample: 9 seconds + apply_rate: + description: + - The rate at which redo logs are synced between the associated databases. + - "Example: `180 Mb per second`" + returned: on success + type: string + sample: 180 Mb per second + protection_mode: + description: + - The protection mode of this Data Guard association. For more information, see + L(Oracle Data Guard Protection Modes,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-protection-modes.htm#SBYDB02000) + in the Oracle Data Guard documentation. + returned: on success + type: string + sample: MAXIMUM_AVAILABILITY + transport_type: + description: + - The redo transport type used by this Data Guard association. For more information, see + L(Redo Transport Services,http://docs.oracle.com/database/122/SBYDB/oracle-data-guard-redo-transport-services.htm#SBYDB00400) + in the Oracle Data Guard documentation. + returned: on success + type: string + sample: SYNC + time_created: + description: + - The date and time the Data Guard association was created. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "database_id": "ocid1.database.oc1..xxxxxxEXAMPLExxxxxx", + "role": "PRIMARY", + "lifecycle_state": "PROVISIONING", + "lifecycle_details": "lifecycle_details_example", + "peer_db_system_id": "ocid1.peerdbsystem.oc1..xxxxxxEXAMPLExxxxxx", + "peer_db_home_id": "ocid1.peerdbhome.oc1..xxxxxxEXAMPLExxxxxx", + "peer_database_id": "ocid1.peerdatabase.oc1..xxxxxxEXAMPLExxxxxx", + "peer_data_guard_association_id": "ocid1.peerdataguardassociation.oc1..xxxxxxEXAMPLExxxxxx", + "peer_role": "PRIMARY", + "apply_lag": "9 seconds", + "apply_rate": "180 Mb per second", + "protection_mode": "MAXIMUM_AVAILABILITY", + "transport_type": "SYNC", + "time_created": "2013-10-20T19:20:30+01:00" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.database import DatabaseClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class DataGuardAssociationFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "database_id", + "data_guard_association_id", + ] + + def get_required_params_for_list(self): + return [ + "database_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_data_guard_association, + database_id=self.module.params.get("database_id"), + data_guard_association_id=self.module.params.get( + "data_guard_association_id" + ), + ) + + def list_resources(self): + optional_list_method_params = [] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_data_guard_associations, + database_id=self.module.params.get("database_id"), + **optional_kwargs + ) + + +DataGuardAssociationFactsHelperCustom = get_custom_class( + "DataGuardAssociationFactsHelperCustom" +) + + +class ResourceFactsHelper( + DataGuardAssociationFactsHelperCustom, DataGuardAssociationFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + database_id=dict(type="str", required=True), + data_guard_association_id=dict(aliases=["id"], type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="data_guard_association", + service_client_class=DatabaseClient, + namespace="database", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(data_guard_associations=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_database_database.py b/plugins/modules/oci_database_database.py index d25d636ddf..6f9e6d8f48 100644 --- a/plugins/modules/oci_database_database.py +++ b/plugins/modules/oci_database_database.py @@ -24,7 +24,8 @@ description: - This module allows the user to update a Database resource in Oracle Cloud Infrastructure - "This resource has the following action operations in the M(oci_database_actions) module: restore." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: database_id: description: @@ -69,10 +70,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ @@ -299,6 +296,26 @@ def get_resource(self): self.client.get_database, database_id=self.module.params.get("database_id"), ) + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + "db_home_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + return dict() + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_databases, **kwargs) + def get_update_model_class(self): return UpdateDatabaseDetails diff --git a/plugins/modules/oci_database_database_actions.py b/plugins/modules/oci_database_database_actions.py index 99b53a6b46..a106f5dc3b 100644 --- a/plugins/modules/oci_database_database_actions.py +++ b/plugins/modules/oci_database_database_actions.py @@ -49,11 +49,9 @@ - The action to perform on the Database. type: str required: true - choices: ["restore"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "restore" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_database_database_facts.py b/plugins/modules/oci_database_database_facts.py index 76fc66407b..aca34995c1 100644 --- a/plugins/modules/oci_database_database_facts.py +++ b/plugins/modules/oci_database_database_facts.py @@ -75,10 +75,7 @@ description: - A filter to return only resources that match the entire database name given. The match is not case sensitive. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_db_home.py b/plugins/modules/oci_database_db_home.py index 1cd6005786..3668237d93 100644 --- a/plugins/modules/oci_database_db_home.py +++ b/plugins/modules/oci_database_db_home.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a DbHome resource in Oracle Cloud Infrastructure - For I(state=present), creates a new Database Home in the specified DB system based on the request parameters you provide. Applies only to bare metal and Exadata DB systems. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: display_name: description: @@ -205,10 +206,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -367,33 +364,36 @@ def get_resource(self): self.client.get_db_home, db_home_id=self.module.params.get("db_home_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "db_system_id", - "vm_cluster_id", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["db_system_id", "vm_cluster_id", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_db_homes, **kwargs) def get_create_model_class(self): @@ -473,8 +473,8 @@ def main(): type="dict", options=dict( backup_id=dict(type="str"), - backup_tde_password=dict(type="str"), - admin_password=dict(type="str", required=True), + backup_tde_password=dict(type="str", no_log=True), + admin_password=dict(type="str", required=True, no_log=True), db_unique_name=dict(type="str"), db_name=dict(type="str"), pdb_name=dict(type="str"), diff --git a/plugins/modules/oci_database_db_home_facts.py b/plugins/modules/oci_database_db_home_facts.py index d829419728..2f710d3163 100644 --- a/plugins/modules/oci_database_db_home_facts.py +++ b/plugins/modules/oci_database_db_home_facts.py @@ -78,10 +78,7 @@ - A filter to return only resources that match the entire display name given. The match is not case sensitive. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_db_home_patch_facts.py b/plugins/modules/oci_database_db_home_patch_facts.py index 4b7736de8f..bb487bc7b0 100644 --- a/plugins/modules/oci_database_db_home_patch_facts.py +++ b/plugins/modules/oci_database_db_home_patch_facts.py @@ -38,10 +38,7 @@ - Required to get a specific db_home_patch. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_db_home_patch_history_entry_facts.py b/plugins/modules/oci_database_db_home_patch_history_entry_facts.py index 392055ee7d..6bbe7ae859 100644 --- a/plugins/modules/oci_database_db_home_patch_history_entry_facts.py +++ b/plugins/modules/oci_database_db_home_patch_history_entry_facts.py @@ -38,10 +38,7 @@ - Required to get a specific db_home_patch_history_entry. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_db_node_actions.py b/plugins/modules/oci_database_db_node_actions.py index ff68c8be89..b09f4f7c2f 100644 --- a/plugins/modules/oci_database_db_node_actions.py +++ b/plugins/modules/oci_database_db_node_actions.py @@ -53,10 +53,7 @@ - "softreset" - "reset" required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_database_db_node_facts.py b/plugins/modules/oci_database_db_node_facts.py index 7f48b157fd..54d7aaaa34 100644 --- a/plugins/modules/oci_database_db_node_facts.py +++ b/plugins/modules/oci_database_db_node_facts.py @@ -74,10 +74,7 @@ - "TERMINATING" - "TERMINATED" - "FAILED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_db_system.py b/plugins/modules/oci_database_db_system.py index fde30dfa70..3fc400e656 100644 --- a/plugins/modules/oci_database_db_system.py +++ b/plugins/modules/oci_database_db_system.py @@ -30,7 +30,8 @@ - "- L(Bare metal and virtual machine DB system default options,https://docs.cloud.oracle.com/Content/Database/Tasks/creatingDBsystem.htm#DefaultOptionsfortheInitialDatabase) - L(Exadata DB system default options,https://docs.cloud.oracle.com/Content/Database/Tasks/exacreatingDBsystem.htm#DefaultOptionsfortheInitialDatabase)" -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -85,9 +86,11 @@ type: str nsg_ids: description: - - A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that this + - "A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that this resource belongs to. Setting this to an empty array after the list is created removes the resource from all NSGs. For more information about NSGs, see L(Security Rules,https://docs.cloud.oracle.com/Content/Network/Concepts/securityrules.htm). + **NsgIds restrictions:** + - Autonomous Databases with private access require at least 1 Network Security Group (NSG). The nsgIds array cannot be empty." type: list backup_network_nsg_ids: description: @@ -373,10 +376,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -553,9 +552,11 @@ sample: ocid1.backupsubnet.oc1..xxxxxxEXAMPLExxxxxx nsg_ids: description: - - A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that this + - "A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that this resource belongs to. Setting this to an empty array after the list is created removes the resource from all NSGs. For more information about NSGs, see L(Security Rules,https://docs.cloud.oracle.com/Content/Network/Concepts/securityrules.htm). + **NsgIds restrictions:** + - Autonomous Databases with private access require at least 1 Network Security Group (NSG). The nsgIds array cannot be empty." returned: on success type: list sample: [] @@ -839,32 +840,36 @@ def get_resource(self): db_system_id=self.module.params.get("db_system_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "availability_domain", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["availability_domain", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_db_systems, **kwargs ) @@ -966,7 +971,7 @@ def main(): db_name=dict(type="str"), db_unique_name=dict(type="str"), pdb_name=dict(type="str"), - admin_password=dict(type="str", required=True), + admin_password=dict(type="str", required=True, no_log=True), character_set=dict(type="str"), ncharacter_set=dict(type="str"), db_workload=dict(type="str", choices=["OLTP", "DSS"]), @@ -980,7 +985,7 @@ def main(): freeform_tags=dict(type="dict"), defined_tags=dict(type="dict"), backup_id=dict(type="str"), - backup_tde_password=dict(type="str"), + backup_tde_password=dict(type="str", no_log=True), ), ), ), diff --git a/plugins/modules/oci_database_db_system_facts.py b/plugins/modules/oci_database_db_system_facts.py index 2dad081e2d..5295e0af39 100644 --- a/plugins/modules/oci_database_db_system_facts.py +++ b/plugins/modules/oci_database_db_system_facts.py @@ -80,10 +80,7 @@ - A filter to return only resources that match the entire display name given. The match is not case sensitive. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -207,9 +204,11 @@ sample: ocid1.backupsubnet.oc1..xxxxxxEXAMPLExxxxxx nsg_ids: description: - - A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that this + - "A list of the L(OCIDs,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the network security groups (NSGs) that this resource belongs to. Setting this to an empty array after the list is created removes the resource from all NSGs. For more information about NSGs, see L(Security Rules,https://docs.cloud.oracle.com/Content/Network/Concepts/securityrules.htm). + **NsgIds restrictions:** + - Autonomous Databases with private access require at least 1 Network Security Group (NSG). The nsgIds array cannot be empty." returned: on success type: list sample: [] diff --git a/plugins/modules/oci_database_db_system_patch_facts.py b/plugins/modules/oci_database_db_system_patch_facts.py index 7c8f523f2b..76680aafbd 100644 --- a/plugins/modules/oci_database_db_system_patch_facts.py +++ b/plugins/modules/oci_database_db_system_patch_facts.py @@ -38,10 +38,7 @@ - Required to get a specific db_system_patch. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_db_system_patch_history_entry_facts.py b/plugins/modules/oci_database_db_system_patch_history_entry_facts.py index 630e0ac6f6..ec5b73f9b0 100644 --- a/plugins/modules/oci_database_db_system_patch_history_entry_facts.py +++ b/plugins/modules/oci_database_db_system_patch_history_entry_facts.py @@ -38,10 +38,7 @@ - Required to get a specific db_system_patch_history_entry. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_db_system_shape_facts.py b/plugins/modules/oci_database_db_system_shape_facts.py index 40049b64e3..18d8303a83 100644 --- a/plugins/modules/oci_database_db_system_shape_facts.py +++ b/plugins/modules/oci_database_db_system_shape_facts.py @@ -36,10 +36,7 @@ description: - The name of the Availability Domain. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_database_db_version_facts.py b/plugins/modules/oci_database_db_version_facts.py index 65240e3f30..d364e6c889 100644 --- a/plugins/modules/oci_database_db_version_facts.py +++ b/plugins/modules/oci_database_db_version_facts.py @@ -40,10 +40,7 @@ - The DB system L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). If provided, filters the results to the set of database versions which are supported for the DB system. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_database_maintenance_run.py b/plugins/modules/oci_database_maintenance_run.py index db29f8ea97..1cb017f830 100644 --- a/plugins/modules/oci_database_maintenance_run.py +++ b/plugins/modules/oci_database_maintenance_run.py @@ -23,7 +23,8 @@ short_description: Manage a MaintenanceRun resource in Oracle Cloud Infrastructure description: - This module allows the user to update a MaintenanceRun resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: maintenance_run_id: description: @@ -35,10 +36,6 @@ description: - If set to false, skips the Maintenance Run. type: bool - compartment_id: - description: - - The compartment L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). - type: str state: description: - The state of the MaintenanceRun. @@ -47,10 +44,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ @@ -201,29 +194,23 @@ def get_resource(self): maintenance_run_id=self.module.params.get("maintenance_run_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_maintenance_runs, **kwargs ) @@ -263,7 +250,6 @@ def main(): dict( maintenance_run_id=dict(aliases=["id"], type="str", required=True), is_enabled=dict(type="bool"), - compartment_id=dict(type="str"), state=dict(type="str", default="present", choices=["present"]), ) ) diff --git a/plugins/modules/oci_database_maintenance_run_facts.py b/plugins/modules/oci_database_maintenance_run_facts.py index 4a26ee7596..c89229fb16 100644 --- a/plugins/modules/oci_database_maintenance_run_facts.py +++ b/plugins/modules/oci_database_maintenance_run_facts.py @@ -91,10 +91,7 @@ description: - A filter to return only resources that match the given availability domain exactly. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_dns_domain_records.py b/plugins/modules/oci_dns_domain_records.py new file mode 100644 index 0000000000..19e1895057 --- /dev/null +++ b/plugins/modules/oci_dns_domain_records.py @@ -0,0 +1,446 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_domain_records +short_description: Manage a DomainRecords resource in Oracle Cloud Infrastructure +description: + - This module allows the user to update, patch and delete a DomainRecords resource in Oracle Cloud Infrastructure + - This module does not support check mode +version_added: "2.9" +author: Oracle (@oracle) +options: + zone_name_or_id: + description: + - The name or OCID of the target zone. + type: str + aliases: ["zone_id", "name", "zone_name", "id"] + required: true + domain: + description: + - The target fully-qualified domain name (FQDN) within the target zone. + type: str + required: true + update_items: + description: + - "" + type: list + suboptions: + domain: + description: + - The fully qualified domain name where the record can be located. + type: str + required: true + record_hash: + description: + - A unique identifier for the record within its zone. + type: str + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + type: bool + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + type: str + required: true + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + type: str + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + type: str + required: true + ttl: + description: + - The Time To Live for the record, in seconds. + type: int + required: true + if_unmodified_since: + description: + - The `If-Unmodified-Since` header field makes the request method + conditional on the selected representation's last modification date being + earlier than or equal to the date provided in the field-value. This + field accomplishes the same purpose as If-Match for cases where the user + agent does not have an entity-tag for the representation. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + type: str + patch_items: + description: + - "" + type: list + suboptions: + domain: + description: + - The fully qualified domain name where the record can be located. + type: str + record_hash: + description: + - A unique identifier for the record within its zone. + type: str + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + type: bool + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + type: str + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + type: str + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + type: str + ttl: + description: + - The Time To Live for the record, in seconds. + type: int + operation: + description: + - A description of how a record relates to a PATCH operation. + - "- `REQUIRE` indicates a precondition that record data **must** already exist. + - `PROHIBIT` indicates a precondition that record data **must not** already exist. + - `ADD` indicates that record data **must** exist after successful application. + - `REMOVE` indicates that record data **must not** exist after successful application." + - " **Note:** `ADD` and `REMOVE` operations can succeed even if + they require no changes when applied, such as when the described + records are already present or absent." + - " **Note:** `ADD` and `REMOVE` operations can describe changes for + more than one record." + - " **Example:** `{ \\"domain\\": \\"www.example.com\\", \\"rtype\\": \\"AAAA\\", \\"ttl\\": 60 }` + specifies a new TTL for every record in the www.example.com AAAA RRSet." + type: str + choices: + - "REQUIRE" + - "PROHIBIT" + - "ADD" + - "REMOVE" + state: + description: + - The state of the DomainRecords. + - Use I(state=present) to update an existing a DomainRecords. + - Use I(state=absent) to delete a DomainRecords. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Update domain_records + oci_dns_domain_records: + update_items: + - domain: www.example.com + record_hash: 8f356bd7e9c2007c5c898f441fb663e9 + is_protected: false + rdata: v=spf1 include:example.net -all + rrset_version: 9 + rtype: TXT + ttl: 30 + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + domain: domain_example + +- name: Delete domain_records + oci_dns_domain_records: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + domain: domain_example + state: absent + +""" + +RETURN = """ +domain_records: + description: + - Details of the DomainRecords resource acted upon by the current operation + returned: on success + type: complex + contains: + domain: + description: + - The fully qualified domain name where the record can be located. + returned: on success + type: string + sample: domain_example + record_hash: + description: + - A unique identifier for the record within its zone. + returned: on success + type: string + sample: record_hash_example + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + returned: on success + type: bool + sample: true + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + returned: on success + type: string + sample: rdata_example + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + returned: on success + type: string + sample: rrset_version_example + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + returned: on success + type: string + sample: rtype_example + ttl: + description: + - The Time To Live for the record, in seconds. + returned: on success + type: int + sample: 56 + sample: { + "domain": "domain_example", + "record_hash": "record_hash_example", + "is_protected": true, + "rdata": "rdata_example", + "rrset_version": "rrset_version_example", + "rtype": "rtype_example", + "ttl": 56 + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + from oci.dns.models import UpdateDomainRecordsDetails + from oci.dns.models import PatchDomainRecordsDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class DomainRecordsHelperGen(OCIResourceHelperBase): + """Supported operations: update, patch, get and delete""" + + def get_module_resource_id_param(self): + return "domain" + + def get_module_resource_id(self): + return self.module.params.get("domain") + + def get_get_fn(self): + return self.client.get_domain_records + + def get_resource(self): + return oci_common_utils.get_default_response_from_resource( + oci_common_utils.list_all_resources( + self.client.get_domain_records, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + ).items + ) + + def get_update_model_class(self): + return UpdateDomainRecordsDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_domain_records, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + update_domain_records_details=update_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_patch_model_class(self): + return PatchDomainRecordsDetails + + def patch_resource(self): + patch_details = self.get_patch_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.patch_domain_records, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + patch_domain_records_details=patch_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.PATCH_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_domain_records, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + def is_resource_dead(self, resource): + # response model returns a collection. Consider existence of a value as active. + if not resource: + return True + return False + + +DomainRecordsHelperCustom = get_custom_class("DomainRecordsHelperCustom") + + +class ResourceHelper(DomainRecordsHelperCustom, DomainRecordsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + zone_name_or_id=dict( + aliases=["zone_id", "name", "zone_name", "id"], + type="str", + required=True, + ), + domain=dict(type="str", required=True), + update_items=dict( + type="list", + elements="dict", + options=dict( + domain=dict(type="str", required=True), + record_hash=dict(type="str"), + is_protected=dict(type="bool"), + rdata=dict(type="str", required=True), + rrset_version=dict(type="str"), + rtype=dict(type="str", required=True), + ttl=dict(type="int", required=True), + ), + ), + if_unmodified_since=dict(type="str"), + compartment_id=dict(type="str"), + patch_items=dict( + type="list", + elements="dict", + options=dict( + domain=dict(type="str"), + record_hash=dict(type="str"), + is_protected=dict(type="bool"), + rdata=dict(type="str"), + rrset_version=dict(type="str"), + rtype=dict(type="str"), + ttl=dict(type="int"), + operation=dict( + type="str", choices=["REQUIRE", "PROHIBIT", "ADD", "REMOVE"] + ), + ), + ), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="domain_records", + service_client_class=DnsClient, + namespace="dns", + ) + + result = dict(changed=False) + + if resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_patch(): + result = resource_helper.patch() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_domain_records_facts.py b/plugins/modules/oci_dns_domain_records_facts.py new file mode 100644 index 0000000000..8fd5219145 --- /dev/null +++ b/plugins/modules/oci_dns_domain_records_facts.py @@ -0,0 +1,255 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_domain_records_facts +short_description: Fetches details about a DomainRecords resource in Oracle Cloud Infrastructure +description: + - Fetches details about a DomainRecords resource in Oracle Cloud Infrastructure + - Gets a list of all records at the specified zone and domain. + The results are sorted by `rtype` in alphabetical order by default. You + can optionally filter and/or sort the results using the listed parameters. +version_added: "2.5" +options: + zone_name_or_id: + description: + - The name or OCID of the target zone. + type: str + aliases: ["zone_id", "name", "zone_name", "id"] + required: true + domain: + description: + - The target fully-qualified domain name (FQDN) within the target zone. + type: str + required: true + if_modified_since: + description: + - The `If-Modified-Since` header field makes a GET or HEAD request method + conditional on the selected representation's modification date being more + recent than the date provided in the field-value. Transfer of the + selected representation's data is avoided if that data has not changed. + type: str + zone_version: + description: + - The version of the zone for which data is requested. + type: str + rtype: + description: + - Search by record type. + Will match any record whose L(type,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4) (case-insensitive) + equals the provided value. + type: str + sort_by: + description: + - The field by which to sort records. + type: str + choices: + - "rtype" + - "ttl" + sort_order: + description: + - The order to sort the resources. + type: str + choices: + - "ASC" + - "DESC" + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific domain_records + oci_dns_domain_records_facts: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + domain: domain_example + +""" + +RETURN = """ +domain_records: + description: + - DomainRecords resource + returned: on success + type: complex + contains: + domain: + description: + - The fully qualified domain name where the record can be located. + returned: on success + type: string + sample: domain_example + record_hash: + description: + - A unique identifier for the record within its zone. + returned: on success + type: string + sample: record_hash_example + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + returned: on success + type: bool + sample: true + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + returned: on success + type: string + sample: rdata_example + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + returned: on success + type: string + sample: rrset_version_example + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + returned: on success + type: string + sample: rtype_example + ttl: + description: + - The Time To Live for the record, in seconds. + returned: on success + type: int + sample: 56 + sample: { + "domain": "domain_example", + "record_hash": "record_hash_example", + "is_protected": true, + "rdata": "rdata_example", + "rrset_version": "rrset_version_example", + "rtype": "rtype_example", + "ttl": 56 + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class DomainRecordsFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "zone_name_or_id", + "domain", + ] + + def get_resource(self): + optional_get_method_params = [ + "if_modified_since", + "zone_version", + "rtype", + "sort_by", + "sort_order", + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.get_default_response_from_resource( + oci_common_utils.list_all_resources( + self.client.get_domain_records, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + **optional_kwargs + ).items + ) + + +DomainRecordsFactsHelperCustom = get_custom_class("DomainRecordsFactsHelperCustom") + + +class ResourceFactsHelper(DomainRecordsFactsHelperCustom, DomainRecordsFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + zone_name_or_id=dict( + aliases=["zone_id", "name", "zone_name", "id"], + type="str", + required=True, + ), + domain=dict(type="str", required=True), + if_modified_since=dict(type="str"), + zone_version=dict(type="str"), + rtype=dict(type="str"), + sort_by=dict(type="str", choices=["rtype", "ttl"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + compartment_id=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="domain_records", + service_client_class=DnsClient, + namespace="dns", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(domain_records=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_rrset.py b/plugins/modules/oci_dns_rrset.py new file mode 100644 index 0000000000..9788b61c58 --- /dev/null +++ b/plugins/modules/oci_dns_rrset.py @@ -0,0 +1,466 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_rrset +short_description: Manage a Rrset resource in Oracle Cloud Infrastructure +description: + - This module allows the user to update, patch and delete a Rrset resource in Oracle Cloud Infrastructure + - This module does not support check mode +version_added: "2.9" +author: Oracle (@oracle) +options: + zone_name_or_id: + description: + - The name or OCID of the target zone. + type: str + aliases: ["zone_id", "name", "zone_name", "id"] + required: true + domain: + description: + - The target fully-qualified domain name (FQDN) within the target zone. + type: str + required: true + rtype: + description: + - The type of the target RRSet within the target zone. + type: str + required: true + update_items: + description: + - "" + type: list + suboptions: + domain: + description: + - The fully qualified domain name where the record can be located. + type: str + required: true + record_hash: + description: + - A unique identifier for the record within its zone. + type: str + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + type: bool + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + type: str + required: true + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + type: str + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + type: str + required: true + ttl: + description: + - The Time To Live for the record, in seconds. + type: int + required: true + if_unmodified_since: + description: + - The `If-Unmodified-Since` header field makes the request method + conditional on the selected representation's last modification date being + earlier than or equal to the date provided in the field-value. This + field accomplishes the same purpose as If-Match for cases where the user + agent does not have an entity-tag for the representation. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + type: str + patch_items: + description: + - "" + type: list + suboptions: + domain: + description: + - The fully qualified domain name where the record can be located. + type: str + record_hash: + description: + - A unique identifier for the record within its zone. + type: str + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + type: bool + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + type: str + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + type: str + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + type: str + ttl: + description: + - The Time To Live for the record, in seconds. + type: int + operation: + description: + - A description of how a record relates to a PATCH operation. + - "- `REQUIRE` indicates a precondition that record data **must** already exist. + - `PROHIBIT` indicates a precondition that record data **must not** already exist. + - `ADD` indicates that record data **must** exist after successful application. + - `REMOVE` indicates that record data **must not** exist after successful application." + - " **Note:** `ADD` and `REMOVE` operations can succeed even if + they require no changes when applied, such as when the described + records are already present or absent." + - " **Note:** `ADD` and `REMOVE` operations can describe changes for + more than one record." + - " **Example:** `{ \\"domain\\": \\"www.example.com\\", \\"rtype\\": \\"AAAA\\", \\"ttl\\": 60 }` + specifies a new TTL for every record in the www.example.com AAAA RRSet." + type: str + choices: + - "REQUIRE" + - "PROHIBIT" + - "ADD" + - "REMOVE" + state: + description: + - The state of the Rrset. + - Use I(state=present) to update an existing a Rrset. + - Use I(state=absent) to delete a Rrset. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Update rrset + oci_dns_rrset: + update_items: + - domain: www.example.com + record_hash: e86155f805706f45b4820db76f0dd71f + is_protected: false + rdata: v=spf1 include:example.net -all + rrset_version: 10 + rtype: TXT + ttl: 60 + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + domain: domain_example + rtype: rtype_example + +- name: Delete rrset + oci_dns_rrset: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + domain: domain_example + rtype: rtype_example + state: absent + +""" + +RETURN = """ +rrset: + description: + - Details of the Rrset resource acted upon by the current operation + returned: on success + type: complex + contains: + items: + description: + - "" + returned: on success + type: complex + contains: + domain: + description: + - The fully qualified domain name where the record can be located. + returned: on success + type: string + sample: domain_example + record_hash: + description: + - A unique identifier for the record within its zone. + returned: on success + type: string + sample: record_hash_example + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + returned: on success + type: bool + sample: true + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + returned: on success + type: string + sample: rdata_example + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + returned: on success + type: string + sample: rrset_version_example + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + returned: on success + type: string + sample: rtype_example + ttl: + description: + - The Time To Live for the record, in seconds. + returned: on success + type: int + sample: 56 + sample: { + "items": [{ + "domain": "domain_example", + "record_hash": "record_hash_example", + "is_protected": true, + "rdata": "rdata_example", + "rrset_version": "rrset_version_example", + "rtype": "rtype_example", + "ttl": 56 + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + from oci.dns.models import UpdateRRSetDetails + from oci.dns.models import PatchRRSetDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class RrsetHelperGen(OCIResourceHelperBase): + """Supported operations: update, patch, get and delete""" + + def get_module_resource_id_param(self): + return "rtype" + + def get_module_resource_id(self): + return self.module.params.get("rtype") + + def get_get_fn(self): + return self.client.get_rr_set + + def get_resource(self): + return oci_common_utils.get_default_response_from_resource( + oci_common_utils.list_all_resources( + self.client.get_rr_set, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + rtype=self.module.params.get("rtype"), + ).items + ) + + def get_update_model_class(self): + return UpdateRRSetDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_rr_set, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + rtype=self.module.params.get("rtype"), + update_rr_set_details=update_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_patch_model_class(self): + return PatchRRSetDetails + + def patch_resource(self): + patch_details = self.get_patch_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.patch_rr_set, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + rtype=self.module.params.get("rtype"), + patch_rr_set_details=patch_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.PATCH_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_rr_set, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + rtype=self.module.params.get("rtype"), + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + def is_resource_dead(self, resource): + # response model returns a collection. Consider existence of a value as active. + if not resource: + return True + return False + + +RrsetHelperCustom = get_custom_class("RrsetHelperCustom") + + +class ResourceHelper(RrsetHelperCustom, RrsetHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + zone_name_or_id=dict( + aliases=["zone_id", "name", "zone_name", "id"], + type="str", + required=True, + ), + domain=dict(type="str", required=True), + rtype=dict(type="str", required=True), + update_items=dict( + type="list", + elements="dict", + options=dict( + domain=dict(type="str", required=True), + record_hash=dict(type="str"), + is_protected=dict(type="bool"), + rdata=dict(type="str", required=True), + rrset_version=dict(type="str"), + rtype=dict(type="str", required=True), + ttl=dict(type="int", required=True), + ), + ), + if_unmodified_since=dict(type="str"), + compartment_id=dict(type="str"), + patch_items=dict( + type="list", + elements="dict", + options=dict( + domain=dict(type="str"), + record_hash=dict(type="str"), + is_protected=dict(type="bool"), + rdata=dict(type="str"), + rrset_version=dict(type="str"), + rtype=dict(type="str"), + ttl=dict(type="int"), + operation=dict( + type="str", choices=["REQUIRE", "PROHIBIT", "ADD", "REMOVE"] + ), + ), + ), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="rrset", + service_client_class=DnsClient, + namespace="dns", + ) + + result = dict(changed=False) + + if resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_patch(): + result = resource_helper.patch() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_rrset_facts.py b/plugins/modules/oci_dns_rrset_facts.py new file mode 100644 index 0000000000..f74d4857e1 --- /dev/null +++ b/plugins/modules/oci_dns_rrset_facts.py @@ -0,0 +1,245 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_rrset_facts +short_description: Fetches details about a Rrset resource in Oracle Cloud Infrastructure +description: + - Fetches details about a Rrset resource in Oracle Cloud Infrastructure + - Gets a list of all records in the specified RRSet. The results are + sorted by `recordHash` by default. +version_added: "2.5" +options: + zone_name_or_id: + description: + - The name or OCID of the target zone. + type: str + aliases: ["zone_id", "name", "zone_name", "id"] + required: true + domain: + description: + - The target fully-qualified domain name (FQDN) within the target zone. + type: str + required: true + rtype: + description: + - The type of the target RRSet within the target zone. + type: str + required: true + if_modified_since: + description: + - The `If-Modified-Since` header field makes a GET or HEAD request method + conditional on the selected representation's modification date being more + recent than the date provided in the field-value. Transfer of the + selected representation's data is avoided if that data has not changed. + type: str + zone_version: + description: + - The version of the zone for which data is requested. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific rrset + oci_dns_rrset_facts: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + domain: domain_example + rtype: rtype_example + +""" + +RETURN = """ +rrset: + description: + - Rrset resource + returned: on success + type: complex + contains: + items: + description: + - "" + returned: on success + type: complex + contains: + domain: + description: + - The fully qualified domain name where the record can be located. + returned: on success + type: string + sample: domain_example + record_hash: + description: + - A unique identifier for the record within its zone. + returned: on success + type: string + sample: record_hash_example + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + returned: on success + type: bool + sample: true + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + returned: on success + type: string + sample: rdata_example + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + returned: on success + type: string + sample: rrset_version_example + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + returned: on success + type: string + sample: rtype_example + ttl: + description: + - The Time To Live for the record, in seconds. + returned: on success + type: int + sample: 56 + sample: { + "items": [{ + "domain": "domain_example", + "record_hash": "record_hash_example", + "is_protected": true, + "rdata": "rdata_example", + "rrset_version": "rrset_version_example", + "rtype": "rtype_example", + "ttl": 56 + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class RrsetFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "zone_name_or_id", + "domain", + "rtype", + ] + + def get_resource(self): + optional_get_method_params = [ + "if_modified_since", + "zone_version", + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.get_default_response_from_resource( + oci_common_utils.list_all_resources( + self.client.get_rr_set, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + domain=self.module.params.get("domain"), + rtype=self.module.params.get("rtype"), + **optional_kwargs + ).items + ) + + +RrsetFactsHelperCustom = get_custom_class("RrsetFactsHelperCustom") + + +class ResourceFactsHelper(RrsetFactsHelperCustom, RrsetFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + zone_name_or_id=dict( + aliases=["zone_id", "name", "zone_name", "id"], + type="str", + required=True, + ), + domain=dict(type="str", required=True), + rtype=dict(type="str", required=True), + if_modified_since=dict(type="str"), + zone_version=dict(type="str"), + compartment_id=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="rrset", + service_client_class=DnsClient, + namespace="dns", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(rrset=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_steering_policy.py b/plugins/modules/oci_dns_steering_policy.py new file mode 100644 index 0000000000..7e38cc5047 --- /dev/null +++ b/plugins/modules/oci_dns_steering_policy.py @@ -0,0 +1,1003 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_steering_policy +short_description: Manage a SteeringPolicy resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a SteeringPolicy resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new steering policy in the specified compartment. For more information on + creating policies with templates, see L(Traffic Management API + Guide,https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm). +version_added: "2.9" +author: Oracle (@oracle) +options: + compartment_id: + description: + - The OCID of the compartment containing the steering policy. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + display_name: + description: + - A user-friendly name for the steering policy. Does not have to be unique and can be changed. + Avoid entering confidential information. + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + aliases: ["name"] + ttl: + description: + - The Time To Live (TTL) for responses from the steering policy, in seconds. + If not specified during creation, a value of 30 seconds will be used. + type: int + health_check_monitor_id: + description: + - The OCID of the health check monitor providing health data about the answers of the + steering policy. A steering policy answer with `rdata` matching a monitored endpoint + will use the health data of that endpoint. A steering policy answer with `rdata` not + matching any monitored endpoint will be assumed healthy. + - "**Note:** To use the Health Check monitoring feature in a steering policy, a monitor + must be created using the Health Checks service first. For more information on how to + create a monitor, please see L(Managing Health Checks,https://docs.cloud.oracle.com/iaas/Content/HealthChecks/Tasks/managinghealthchecks.htm)." + type: str + template: + description: + - A set of predefined rules based on the desired purpose of the steering policy. Each + template utilizes Traffic Management's rules in a different order to produce the desired + results when answering DNS queries. + - "**Example:** The `FAILOVER` template determines answers by filtering the policy's answers + using the `FILTER` rule first, then the following rules in succession: `HEALTH`, `PRIORITY`, + and `LIMIT`. This gives the domain dynamic failover capability." + - "It is **strongly recommended** to use a template other than `CUSTOM` when creating + a steering policy." + - All templates require the rule order to begin with an unconditional `FILTER` rule that keeps + answers contingent upon `answer.isDisabled != true`, except for `CUSTOM`. A defined + `HEALTH` rule must follow the `FILTER` rule if the policy references a `healthCheckMonitorId`. + The last rule of a template must must be a `LIMIT` rule. For more information about templates + and code examples, see L(Traffic Management API + Guide,https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm). + - "**Template Types**" + - "* `FAILOVER` - Uses health check information on your endpoints to determine which DNS answers + to serve. If an endpoint fails a health check, the answer for that endpoint will be removed + from the list of available answers until the endpoint is detected as healthy." + - "* `LOAD_BALANCE` - Distributes web traffic to specified endpoints based on defined weights." + - "* `ROUTE_BY_GEO` - Answers DNS queries based on the query's geographic location. For a list of geographic + locations to route by, see L(Traffic Management Geographic + Locations,https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Reference/trafficmanagementgeo.htm)." + - "* `ROUTE_BY_ASN` - Answers DNS queries based on the query's originating ASN." + - "* `ROUTE_BY_IP` - Answers DNS queries based on the query's IP address." + - "* `CUSTOM` - Allows a customized configuration of rules." + - Required for create using I(state=present). + type: str + choices: + - "FAILOVER" + - "LOAD_BALANCE" + - "ROUTE_BY_GEO" + - "ROUTE_BY_ASN" + - "ROUTE_BY_IP" + - "CUSTOM" + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + answers: + description: + - The set of all answers that can potentially issue from the steering policy. + type: list + suboptions: + name: + description: + - A user-friendly name for the answer, unique within the steering policy. + An answer's `name` property can be referenced in `answerCondition` properties + of rules using `answer.name`. + - "**Example:**" + - | + " \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.name == 'server 1'\\", + \\"shouldKeep\\": true + } + ] + } + ]" + type: str + required: true + rtype: + description: + - The canonical name for the record's type. Only A, AAAA, and CNAME are supported. For more + information, see L(Supported DNS Resource Record Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm). + type: str + required: true + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm). + type: str + required: true + pool: + description: + - "The freeform name of a group of one or more records in which this record is included, + such as \\"LAX data center\\". An answer's `pool` property can be referenced in `answerCondition` + properties of rules using `answer.pool`." + - "**Example:**" + - | + " \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.pool == 'US East Servers'\\", + \\"shouldKeep\\": true + } + ] + } + ]" + type: str + is_disabled: + description: + - Set this property to `true` to indicate that the answer is administratively disabled, + such as when the corresponding server is down for maintenance. An answer's `isDisabled` + property can be referenced in `answerCondition` properties in rules using `answer.isDisabled`. + - | + "**Example:** + \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.isDisabled != true\\", + \\"shouldKeep\\": true + } + ] + }," + type: bool + rules: + description: + - The series of rules that will be processed in sequence to reduce the pool of answers + to a response for any given request. + - The first rule receives a shuffled list of all answers, and every other rule receives + the list of answers emitted by the one preceding it. The last rule populates the + response. + type: list + suboptions: + description: + description: + - A user-defined description of the rule's purpose or behavior. + type: str + rule_type: + description: + - "The type of a rule determines its sorting/filtering behavior. + * `FILTER` - Filters the list of answers based on their defined boolean data. Answers remain + only if their `shouldKeep` value is `true`." + - "* `HEALTH` - Removes answers from the list if their `rdata` matches a target in the + health check monitor referenced by the steering policy and the target is reported down." + - "* `WEIGHTED` - Uses a number between 0 and 255 to determine how often an answer will be served + in relation to other answers. Anwers with a higher weight will be served more frequently." + - "* `PRIORITY` - Uses a defined rank value of answers to determine which answer to serve, + moving those with the lowest values to the beginning of the list without changing the + relative order of those with the same value. Answers can be given a value between `0` and `255`." + - "* `LIMIT` - Filters answers that are too far down the list. Parameter `defaultCount` + specifies how many answers to keep. **Example:** If `defaultCount` has a value of `2` and + there are five answers left, when the `LIMIT` rule is processed, only the first two answers + will remain in the list." + type: str + choices: + - "FILTER" + - "WEIGHTED" + - "LIMIT" + - "HEALTH" + - "PRIORITY" + required: true + cases: + description: + - An array of `caseConditions`. A rule may optionally include a sequence of cases defining alternate + configurations for how it should behave during processing for any given DNS query. When a rule has + no sequence of `cases`, it is always evaluated with the same configuration during processing. When + a rule has an empty sequence of `cases`, it is always ignored during processing. When a rule has a + non-empty sequence of `cases`, its behavior during processing is configured by the first matching + `case` in the sequence. When a rule has no matching cases the rule is ignored. A rule case with no + `caseCondition` always matches. A rule case with a `caseCondition` matches only when that expression + evaluates to true for the given query. + type: list + suboptions: + case_condition: + description: + - "An expression that uses conditions at the time of a DNS query to indicate + whether a case matches. Conditions may include the geographical location, IP + subnet, or ASN the DNS query originated. **Example:** If you have an + office that uses the subnet `192.0.2.0/24` you could use a `caseCondition` + expression `query.client.subnet in ('192.0.2.0/24')` to define a case that + matches queries from that office." + type: str + answer_data: + description: + - An array of `SteeringPolicyFilterAnswerData` objects. + - Applicable when rule_type is one of ['FILTER', 'WEIGHTED', 'PRIORITY'] + type: list + suboptions: + answer_condition: + description: + - An expression that is used to select a set of answers that match a condition. For example, answers with matching pool + properties. + - Applicable when rule_type is one of ['FILTER', 'WEIGHTED', 'PRIORITY'] + type: str + should_keep: + description: + - Keeps the answer only if the value is `true`. + - Applicable when rule_type is 'FILTER' + type: bool + value: + description: + - The weight assigned to the set of selected answers. Answers with a higher weight will be served + more frequently. Answers can be given a value between `0` and `255`. + - Required when rule_type is one of ['WEIGHTED', 'PRIORITY'] + type: int + count: + description: + - "The number of answers allowed to remain after the limit rule has been processed, keeping only the + first of the remaining answers in the list. Example: If the `count` property is set to `2` and + four answers remain before the limit rule is processed, only the first two answers in the list will + remain after the limit rule has been processed." + - Required when rule_type is 'LIMIT' + type: int + default_answer_data: + description: + - Defines a default set of answer conditions and values that are applied to an answer when + `cases` is not defined for the rule, or a matching case does not have any matching + `answerCondition`s in its `answerData`. `defaultAnswerData` is not applied if `cases` is + defined and there are no matching cases. In this scenario, the next rule will be processed. + - Applicable when rule_type is one of ['FILTER', 'WEIGHTED', 'PRIORITY'] + type: list + suboptions: + answer_condition: + description: + - An expression that is used to select a set of answers that match a condition. For example, answers with matching pool properties. + - Applicable when rule_type is one of ['FILTER', 'WEIGHTED', 'PRIORITY'] + type: str + should_keep: + description: + - Keeps the answer only if the value is `true`. + - Applicable when rule_type is 'FILTER' + type: bool + value: + description: + - The weight assigned to the set of selected answers. Answers with a higher weight will be served + more frequently. Answers can be given a value between `0` and `255`. + - Required when rule_type is one of ['WEIGHTED', 'PRIORITY'] + type: int + default_count: + description: + - "Defines a default count if `cases` is not defined for the rule or a matching case does + not define `count`. `defaultCount` is **not** applied if `cases` is defined and there + are no matching cases. In this scenario, the next rule will be processed. If no rules + remain to be processed, the answer will be chosen from the remaining list of answers." + - Applicable when rule_type is 'LIMIT' + type: int + steering_policy_id: + description: + - The OCID of the target steering policy. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + if_unmodified_since: + description: + - The `If-Unmodified-Since` header field makes the request method + conditional on the selected representation's last modification date being + earlier than or equal to the date provided in the field-value. This + field accomplishes the same purpose as If-Match for cases where the user + agent does not have an entity-tag for the representation. + type: str + state: + description: + - The state of the SteeringPolicy. + - Use I(state=present) to create or update a SteeringPolicy. + - Use I(state=absent) to delete a SteeringPolicy. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create steering_policy + oci_dns_steering_policy: + compartment_id: ocid1.compartment.oc1.. + display_name: failover between endpoints + ttl: 30 + health_check_monitor_id: ocid1.httpmonitor.oc1.. + template: FAILOVER + answers: + - name: server-primary + rtype: A + rdata: 192.0.2.0 + pool: primary + - name: server-secondary + rtype: A + rdata: 192.0.4.6 + pool: secondary + rules: + - rule_type: FILTER + default_answer_data: + - answer_condition: answer.isDisabled != true + should_keep: true + - rule_type: HEALTH + - rule_type: PRIORITY + default_answer_data: + - answer_condition: answer.pool == 'primary' + value: 1 + - answer_condition: answer.pool == 'secondary' + value: 99 + - rule_type: LIMIT + default_count: 1 + +- name: Update steering_policy using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_steering_policy: + compartment_id: ocid1.compartment.oc1.. + display_name: LA data center failover + ttl: 30 + health_check_monitor_id: ocid1.httpmonitor.oc1.. + template: FAILOVER + answers: + - name: server-primary + rtype: A + rdata: 192.0.2.0 + pool: primary + - name: server-secondary + rtype: A + rdata: 192.0.4.1 + pool: secondary + rules: + - rule_type: FILTER + default_answer_data: + - answer_condition: answer.isDisabled != true + should_keep: true + - rule_type: HEALTH + - rule_type: PRIORITY + default_answer_data: + - answer_condition: answer.pool == 'primary' + value: 1 + - answer_condition: answer.pool == 'secondary' + value: 99 + - rule_type: LIMIT + default_count: 1 + +- name: Update steering_policy + oci_dns_steering_policy: + steering_policy_id: ocid1.steeringpolicy.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete steering_policy + oci_dns_steering_policy: + steering_policy_id: ocid1.steeringpolicy.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete steering_policy using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_steering_policy: + compartment_id: ocid1.compartment.oc1.. + display_name: failover between endpoints + state: absent + +""" + +RETURN = """ +steering_policy: + description: + - Details of the SteeringPolicy resource acted upon by the current operation + returned: on success + type: complex + contains: + compartment_id: + description: + - The OCID of the compartment containing the steering policy. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - A user-friendly name for the steering policy. Does not have to be unique and can be changed. + Avoid entering confidential information. + returned: on success + type: string + sample: display_name_example + ttl: + description: + - The Time To Live (TTL) for responses from the steering policy, in seconds. + If not specified during creation, a value of 30 seconds will be used. + returned: on success + type: int + sample: 56 + health_check_monitor_id: + description: + - The OCID of the health check monitor providing health data about the answers of the + steering policy. A steering policy answer with `rdata` matching a monitored endpoint + will use the health data of that endpoint. A steering policy answer with `rdata` not + matching any monitored endpoint will be assumed healthy. + - "**Note:** To use the Health Check monitoring feature in a steering policy, a monitor + must be created using the Health Checks service first. For more information on how to + create a monitor, please see L(Managing Health + Checks,https://docs.cloud.oracle.com/iaas/Content/HealthChecks/Tasks/managinghealthchecks.htm)." + returned: on success + type: string + sample: ocid1.healthcheckmonitor.oc1..xxxxxxEXAMPLExxxxxx + template: + description: + - A set of predefined rules based on the desired purpose of the steering policy. Each + template utilizes Traffic Management's rules in a different order to produce the desired + results when answering DNS queries. + - "**Example:** The `FAILOVER` template determines answers by filtering the policy's answers + using the `FILTER` rule first, then the following rules in succession: `HEALTH`, `PRIORITY`, + and `LIMIT`. This gives the domain dynamic failover capability." + - "It is **strongly recommended** to use a template other than `CUSTOM` when creating + a steering policy." + - All templates require the rule order to begin with an unconditional `FILTER` rule that keeps + answers contingent upon `answer.isDisabled != true`, except for `CUSTOM`. A defined + `HEALTH` rule must follow the `FILTER` rule if the policy references a `healthCheckMonitorId`. + The last rule of a template must must be a `LIMIT` rule. For more information about templates + and code examples, see L(Traffic Management API + Guide,https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm). + - "**Template Types**" + - "* `FAILOVER` - Uses health check information on your endpoints to determine which DNS answers + to serve. If an endpoint fails a health check, the answer for that endpoint will be removed + from the list of available answers until the endpoint is detected as healthy." + - "* `LOAD_BALANCE` - Distributes web traffic to specified endpoints based on defined weights." + - "* `ROUTE_BY_GEO` - Answers DNS queries based on the query's geographic location. For a list of geographic + locations to route by, see L(Traffic Management Geographic + Locations,https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Reference/trafficmanagementgeo.htm)." + - "* `ROUTE_BY_ASN` - Answers DNS queries based on the query's originating ASN." + - "* `ROUTE_BY_IP` - Answers DNS queries based on the query's IP address." + - "* `CUSTOM` - Allows a customized configuration of rules." + returned: on success + type: string + sample: FAILOVER + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + answers: + description: + - The set of all answers that can potentially issue from the steering policy. + returned: on success + type: complex + contains: + name: + description: + - A user-friendly name for the answer, unique within the steering policy. + An answer's `name` property can be referenced in `answerCondition` properties + of rules using `answer.name`. + - "**Example:**" + - | + " \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.name == 'server 1'\\", + \\"shouldKeep\\": true + } + ] + } + ]" + returned: on success + type: string + sample: name_example + rtype: + description: + - The canonical name for the record's type. Only A, AAAA, and CNAME are supported. For more + information, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm). + returned: on success + type: string + sample: rtype_example + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm). + returned: on success + type: string + sample: rdata_example + pool: + description: + - "The freeform name of a group of one or more records in which this record is included, + such as \\"LAX data center\\". An answer's `pool` property can be referenced in `answerCondition` + properties of rules using `answer.pool`." + - "**Example:**" + - | + " \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.pool == 'US East Servers'\\", + \\"shouldKeep\\": true + } + ] + } + ]" + returned: on success + type: string + sample: pool_example + is_disabled: + description: + - Set this property to `true` to indicate that the answer is administratively disabled, + such as when the corresponding server is down for maintenance. An answer's `isDisabled` + property can be referenced in `answerCondition` properties in rules using `answer.isDisabled`. + - | + "**Example:** + \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.isDisabled != true\\", + \\"shouldKeep\\": true + } + ] + }," + returned: on success + type: bool + sample: true + rules: + description: + - The series of rules that will be processed in sequence to reduce the pool of answers + to a response for any given request. + - The first rule receives a shuffled list of all answers, and every other rule receives + the list of answers emitted by the one preceding it. The last rule populates the + response. + returned: on success + type: complex + contains: + description: + description: + - A user-defined description of the rule's purpose or behavior. + returned: on success + type: string + sample: description_example + rule_type: + description: + - "The type of a rule determines its sorting/filtering behavior. + * `FILTER` - Filters the list of answers based on their defined boolean data. Answers remain + only if their `shouldKeep` value is `true`." + - "* `HEALTH` - Removes answers from the list if their `rdata` matches a target in the + health check monitor referenced by the steering policy and the target is reported down." + - "* `WEIGHTED` - Uses a number between 0 and 255 to determine how often an answer will be served + in relation to other answers. Anwers with a higher weight will be served more frequently." + - "* `PRIORITY` - Uses a defined rank value of answers to determine which answer to serve, + moving those with the lowest values to the beginning of the list without changing the + relative order of those with the same value. Answers can be given a value between `0` and `255`." + - "* `LIMIT` - Filters answers that are too far down the list. Parameter `defaultCount` + specifies how many answers to keep. **Example:** If `defaultCount` has a value of `2` and + there are five answers left, when the `LIMIT` rule is processed, only the first two answers + will remain in the list." + returned: on success + type: string + sample: FILTER + cases: + description: + - An array of `caseConditions`. A rule may optionally include a sequence of cases defining alternate + configurations for how it should behave during processing for any given DNS query. When a rule has + no sequence of `cases`, it is always evaluated with the same configuration during processing. When + a rule has an empty sequence of `cases`, it is always ignored during processing. When a rule has a + non-empty sequence of `cases`, its behavior during processing is configured by the first matching + `case` in the sequence. When a rule has no matching cases the rule is ignored. A rule case with no + `caseCondition` always matches. A rule case with a `caseCondition` matches only when that expression + evaluates to true for the given query. + returned: on success + type: complex + contains: + case_condition: + description: + - "An expression that uses conditions at the time of a DNS query to indicate + whether a case matches. Conditions may include the geographical location, IP + subnet, or ASN the DNS query originated. **Example:** If you have an + office that uses the subnet `192.0.2.0/24` you could use a `caseCondition` + expression `query.client.subnet in ('192.0.2.0/24')` to define a case that + matches queries from that office." + returned: on success + type: string + sample: query.client.address in (subnet '198.51.100.0/24') + answer_data: + description: + - An array of `SteeringPolicyFilterAnswerData` objects. + returned: on success + type: complex + contains: + answer_condition: + description: + - An expression that is used to select a set of answers that match a condition. For example, answers with matching pool + properties. + returned: on success + type: string + sample: answer.pool == 'A' + should_keep: + description: + - Keeps the answer only if the value is `true`. + returned: on success + type: bool + sample: true + default_answer_data: + description: + - Defines a default set of answer conditions and values that are applied to an answer when + `cases` is not defined for the rule, or a matching case does not have any matching + `answerCondition`s in its `answerData`. `defaultAnswerData` is not applied if `cases` is + defined and there are no matching cases. In this scenario, the next rule will be processed. + returned: on success + type: complex + contains: + answer_condition: + description: + - An expression that is used to select a set of answers that match a condition. For example, answers with matching pool + properties. + returned: on success + type: string + sample: answer.pool == 'A' + should_keep: + description: + - Keeps the answer only if the value is `true`. + returned: on success + type: bool + sample: true + default_count: + description: + - "Defines a default count if `cases` is not defined for the rule or a matching case does + not define `count`. `defaultCount` is **not** applied if `cases` is defined and there + are no matching cases. In this scenario, the next rule will be processed. If no rules + remain to be processed, the answer will be chosen from the remaining list of answers." + returned: on success + type: int + sample: 56 + _self: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + id: + description: + - The OCID of the resource. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + time_created: + description: + - The date and time the resource was created, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + lifecycle_state: + description: + - The current state of the resource. + returned: on success + type: string + sample: ACTIVE + sample: { + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "ttl": 56, + "health_check_monitor_id": "ocid1.healthcheckmonitor.oc1..xxxxxxEXAMPLExxxxxx", + "template": "FAILOVER", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "answers": [{ + "name": "name_example", + "rtype": "rtype_example", + "rdata": "rdata_example", + "pool": "pool_example", + "is_disabled": true + }], + "rules": [{ + "description": "description_example", + "rule_type": "FILTER", + "cases": [{ + "case_condition": "query.client.address in (subnet '198.51.100.0/24')", + "answer_data": [{ + "answer_condition": "answer.pool == 'A'", + "should_keep": true + }] + }], + "default_answer_data": [{ + "answer_condition": "answer.pool == 'A'", + "should_keep": true + }], + "default_count": 56 + }], + "_self": "_self_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "time_created": "2013-10-20T19:20:30+01:00", + "lifecycle_state": "ACTIVE" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + from oci.dns.models import CreateSteeringPolicyDetails + from oci.dns.models import UpdateSteeringPolicyDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SteeringPolicyHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "steering_policy_id" + + def get_module_resource_id(self): + return self.module.params.get("steering_policy_id") + + def get_get_fn(self): + return self.client.get_steering_policy + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_steering_policy, + steering_policy_id=self.module.params.get("steering_policy_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ( + ["display_name"] + if self._use_name_as_identifier() + else ["display_name", "health_check_monitor_id", "template"] + ) + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_steering_policies, **kwargs + ) + + def get_create_model_class(self): + return CreateSteeringPolicyDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_steering_policy, + call_fn_args=(), + call_fn_kwargs=dict(create_steering_policy_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateSteeringPolicyDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_steering_policy, + call_fn_args=(), + call_fn_kwargs=dict( + steering_policy_id=self.module.params.get("steering_policy_id"), + update_steering_policy_details=update_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_steering_policy, + call_fn_args=(), + call_fn_kwargs=dict( + steering_policy_id=self.module.params.get("steering_policy_id"), + if_unmodified_since=self.module.params.get("if_unmodified_since"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +SteeringPolicyHelperCustom = get_custom_class("SteeringPolicyHelperCustom") + + +class ResourceHelper(SteeringPolicyHelperCustom, SteeringPolicyHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + compartment_id=dict(type="str"), + display_name=dict(aliases=["name"], type="str"), + ttl=dict(type="int"), + health_check_monitor_id=dict(type="str"), + template=dict( + type="str", + choices=[ + "FAILOVER", + "LOAD_BALANCE", + "ROUTE_BY_GEO", + "ROUTE_BY_ASN", + "ROUTE_BY_IP", + "CUSTOM", + ], + ), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + answers=dict( + type="list", + elements="dict", + options=dict( + name=dict(type="str", required=True), + rtype=dict(type="str", required=True), + rdata=dict(type="str", required=True), + pool=dict(type="str"), + is_disabled=dict(type="bool"), + ), + ), + rules=dict( + type="list", + elements="dict", + options=dict( + description=dict(type="str"), + rule_type=dict( + type="str", + required=True, + choices=["FILTER", "WEIGHTED", "LIMIT", "HEALTH", "PRIORITY"], + ), + cases=dict( + type="list", + elements="dict", + options=dict( + case_condition=dict(type="str"), + answer_data=dict( + type="list", + elements="dict", + options=dict( + answer_condition=dict(type="str"), + should_keep=dict(type="bool"), + value=dict(type="int"), + ), + ), + count=dict(type="int"), + ), + ), + default_answer_data=dict( + type="list", + elements="dict", + options=dict( + answer_condition=dict(type="str"), + should_keep=dict(type="bool"), + value=dict(type="int"), + ), + ), + default_count=dict(type="int"), + ), + ), + steering_policy_id=dict(aliases=["id"], type="str"), + if_unmodified_since=dict(type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="steering_policy", + service_client_class=DnsClient, + namespace="dns", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_steering_policy_attachment.py b/plugins/modules/oci_dns_steering_policy_attachment.py new file mode 100644 index 0000000000..1c3b0d85ec --- /dev/null +++ b/plugins/modules/oci_dns_steering_policy_attachment.py @@ -0,0 +1,395 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_steering_policy_attachment +short_description: Manage a SteeringPolicyAttachment resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a SteeringPolicyAttachment resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new attachment between a steering policy and a domain, giving the + policy permission to answer queries for the specified domain. A steering policy must + be attached to a domain for the policy to answer DNS queries for that domain. + - For the purposes of access control, the attachment is automatically placed + into the same compartment as the domain's zone. +version_added: "2.9" +author: Oracle (@oracle) +options: + steering_policy_id: + description: + - The OCID of the attached steering policy. + - Required for create using I(state=present). + type: str + zone_id: + description: + - The OCID of the attached zone. + - Required for create using I(state=present). + type: str + domain_name: + description: + - The attached domain within the attached zone. + - Required for create using I(state=present). + type: str + display_name: + description: + - A user-friendly name for the steering policy attachment. + Does not have to be unique and can be changed. + Avoid entering confidential information. + - Required for create, update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + aliases: ["name"] + steering_policy_attachment_id: + description: + - The OCID of the target steering policy attachment. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + if_unmodified_since: + description: + - The `If-Unmodified-Since` header field makes the request method + conditional on the selected representation's last modification date being + earlier than or equal to the date provided in the field-value. This + field accomplishes the same purpose as If-Match for cases where the user + agent does not have an entity-tag for the representation. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + state: + description: + - The state of the SteeringPolicyAttachment. + - Use I(state=present) to create or update a SteeringPolicyAttachment. + - Use I(state=absent) to delete a SteeringPolicyAttachment. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create steering_policy_attachment + oci_dns_steering_policy_attachment: + steering_policy_id: ocid1.dnspolicy.oc1.. + zone_id: ocid1.dns-zone.oc1.. + domain_name: example.com + display_name: attached to example + +- name: Update steering_policy_attachment using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_steering_policy_attachment: + display_name: IP prefix steering + +- name: Update steering_policy_attachment + oci_dns_steering_policy_attachment: + steering_policy_attachment_id: ocid1.steeringpolicyattachment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete steering_policy_attachment + oci_dns_steering_policy_attachment: + steering_policy_attachment_id: ocid1.steeringpolicyattachment.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete steering_policy_attachment using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_steering_policy_attachment: + display_name: attached to example + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +steering_policy_attachment: + description: + - Details of the SteeringPolicyAttachment resource acted upon by the current operation + returned: on success + type: complex + contains: + steering_policy_id: + description: + - The OCID of the attached steering policy. + returned: on success + type: string + sample: ocid1.steeringpolicy.oc1..xxxxxxEXAMPLExxxxxx + zone_id: + description: + - The OCID of the attached zone. + returned: on success + type: string + sample: ocid1.zone.oc1..xxxxxxEXAMPLExxxxxx + domain_name: + description: + - The attached domain within the attached zone. + returned: on success + type: string + sample: domain_name_example + display_name: + description: + - A user-friendly name for the steering policy attachment. + Does not have to be unique and can be changed. + Avoid entering confidential information. + returned: on success + type: string + sample: display_name_example + rtypes: + description: + - The record types covered by the attachment at the domain. The set of record types is + determined by aggregating the record types from the answers defined in the steering + policy. + returned: on success + type: list + sample: [] + compartment_id: + description: + - The OCID of the compartment containing the steering policy attachment. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + _self: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + id: + description: + - The OCID of the resource. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + time_created: + description: + - The date and time the resource was created, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + lifecycle_state: + description: + - The current state of the resource. + returned: on success + type: string + sample: CREATING + sample: { + "steering_policy_id": "ocid1.steeringpolicy.oc1..xxxxxxEXAMPLExxxxxx", + "zone_id": "ocid1.zone.oc1..xxxxxxEXAMPLExxxxxx", + "domain_name": "domain_name_example", + "display_name": "display_name_example", + "rtypes": [], + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "_self": "_self_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "time_created": "2013-10-20T19:20:30+01:00", + "lifecycle_state": "CREATING" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + from oci.dns.models import CreateSteeringPolicyAttachmentDetails + from oci.dns.models import UpdateSteeringPolicyAttachmentDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SteeringPolicyAttachmentHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "steering_policy_attachment_id" + + def get_module_resource_id(self): + return self.module.params.get("steering_policy_attachment_id") + + def get_get_fn(self): + return self.client.get_steering_policy_attachment + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_steering_policy_attachment, + steering_policy_attachment_id=self.module.params.get( + "steering_policy_attachment_id" + ), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name", "steering_policy_id", "zone_id"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_steering_policy_attachments, **kwargs + ) + + def get_create_model_class(self): + return CreateSteeringPolicyAttachmentDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_steering_policy_attachment, + call_fn_args=(), + call_fn_kwargs=dict( + create_steering_policy_attachment_details=create_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateSteeringPolicyAttachmentDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_steering_policy_attachment, + call_fn_args=(), + call_fn_kwargs=dict( + steering_policy_attachment_id=self.module.params.get( + "steering_policy_attachment_id" + ), + update_steering_policy_attachment_details=update_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_steering_policy_attachment, + call_fn_args=(), + call_fn_kwargs=dict( + steering_policy_attachment_id=self.module.params.get( + "steering_policy_attachment_id" + ), + if_unmodified_since=self.module.params.get("if_unmodified_since"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +SteeringPolicyAttachmentHelperCustom = get_custom_class( + "SteeringPolicyAttachmentHelperCustom" +) + + +class ResourceHelper( + SteeringPolicyAttachmentHelperCustom, SteeringPolicyAttachmentHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + steering_policy_id=dict(type="str"), + zone_id=dict(type="str"), + domain_name=dict(type="str"), + display_name=dict(aliases=["name"], type="str"), + steering_policy_attachment_id=dict(aliases=["id"], type="str"), + if_unmodified_since=dict(type="str"), + compartment_id=dict(type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="steering_policy_attachment", + service_client_class=DnsClient, + namespace="dns", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_steering_policy_attachment_facts.py b/plugins/modules/oci_dns_steering_policy_attachment_facts.py new file mode 100644 index 0000000000..d430da6758 --- /dev/null +++ b/plugins/modules/oci_dns_steering_policy_attachment_facts.py @@ -0,0 +1,343 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_steering_policy_attachment_facts +short_description: Fetches details about one or multiple SteeringPolicyAttachment resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple SteeringPolicyAttachment resources in Oracle Cloud Infrastructure + - Lists the steering policy attachments in the specified compartment. + - If I(steering_policy_attachment_id) is specified, the details of a single SteeringPolicyAttachment will be returned. +version_added: "2.5" +options: + steering_policy_attachment_id: + description: + - The OCID of the target steering policy attachment. + - Required to get a specific steering_policy_attachment. + type: str + aliases: ["id"] + if_modified_since: + description: + - The `If-Modified-Since` header field makes a GET or HEAD request method + conditional on the selected representation's modification date being more + recent than the date provided in the field-value. Transfer of the + selected representation's data is avoided if that data has not changed. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + - Required to list multiple steering_policy_attachments. + type: str + id: + description: + - The OCID of a resource. + type: str + display_name: + description: + - The displayName of a resource. + type: str + aliases: ["name"] + steering_policy_id: + description: + - Search by steering policy OCID. + Will match any resource whose steering policy ID matches the provided value. + type: str + zone_id: + description: + - Search by zone OCID. + Will match any resource whose zone ID matches the provided value. + type: str + domain: + description: + - Search by domain. + Will match any record whose domain (case-insensitive) equals the provided value. + type: str + domain_contains: + description: + - Search by domain. + Will match any record whose domain (case-insensitive) contains the provided value. + type: str + time_created_greater_than_or_equal_to: + description: + - An L(RFC 3339,https://www.ietf.org/rfc/rfc3339.txt) timestamp that states + all returned resources were created on or after the indicated time. + type: str + time_created_less_than: + description: + - An L(RFC 3339,https://www.ietf.org/rfc/rfc3339.txt) timestamp that states + all returned resources were created before the indicated time. + type: str + lifecycle_state: + description: + - The state of a resource. + type: str + choices: + - "CREATING" + - "ACTIVE" + - "DELETING" + sort_by: + description: + - The field by which to sort steering policy attachments. If unspecified, defaults to `timeCreated`. + type: str + choices: + - "displayName" + - "timeCreated" + - "domainName" + sort_order: + description: + - The order to sort the resources. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List steering_policy_attachments + oci_dns_steering_policy_attachment_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific steering_policy_attachment + oci_dns_steering_policy_attachment_facts: + steering_policy_attachment_id: ocid1.steeringpolicyattachment.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +steering_policy_attachments: + description: + - List of SteeringPolicyAttachment resources + returned: on success + type: complex + contains: + steering_policy_id: + description: + - The OCID of the attached steering policy. + returned: on success + type: string + sample: ocid1.steeringpolicy.oc1..xxxxxxEXAMPLExxxxxx + zone_id: + description: + - The OCID of the attached zone. + returned: on success + type: string + sample: ocid1.zone.oc1..xxxxxxEXAMPLExxxxxx + domain_name: + description: + - The attached domain within the attached zone. + returned: on success + type: string + sample: domain_name_example + display_name: + description: + - A user-friendly name for the steering policy attachment. + Does not have to be unique and can be changed. + Avoid entering confidential information. + returned: on success + type: string + sample: display_name_example + rtypes: + description: + - The record types covered by the attachment at the domain. The set of record types is + determined by aggregating the record types from the answers defined in the steering + policy. + returned: on success + type: list + sample: [] + compartment_id: + description: + - The OCID of the compartment containing the steering policy attachment. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + _self: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + id: + description: + - The OCID of the resource. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + time_created: + description: + - The date and time the resource was created, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + lifecycle_state: + description: + - The current state of the resource. + returned: on success + type: string + sample: CREATING + sample: [{ + "steering_policy_id": "ocid1.steeringpolicy.oc1..xxxxxxEXAMPLExxxxxx", + "zone_id": "ocid1.zone.oc1..xxxxxxEXAMPLExxxxxx", + "domain_name": "domain_name_example", + "display_name": "display_name_example", + "rtypes": [], + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "_self": "_self_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "time_created": "2013-10-20T19:20:30+01:00", + "lifecycle_state": "CREATING" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SteeringPolicyAttachmentFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "steering_policy_attachment_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + optional_get_method_params = [ + "if_modified_since", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_steering_policy_attachment, + steering_policy_attachment_id=self.module.params.get( + "steering_policy_attachment_id" + ), + **optional_kwargs + ) + + def list_resources(self): + optional_list_method_params = [ + "id", + "display_name", + "steering_policy_id", + "zone_id", + "domain", + "domain_contains", + "time_created_greater_than_or_equal_to", + "time_created_less_than", + "lifecycle_state", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_steering_policy_attachments, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +SteeringPolicyAttachmentFactsHelperCustom = get_custom_class( + "SteeringPolicyAttachmentFactsHelperCustom" +) + + +class ResourceFactsHelper( + SteeringPolicyAttachmentFactsHelperCustom, SteeringPolicyAttachmentFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + steering_policy_attachment_id=dict(aliases=["id"], type="str"), + if_modified_since=dict(type="str"), + compartment_id=dict(type="str"), + id=dict(type="str"), + display_name=dict(aliases=["name"], type="str"), + steering_policy_id=dict(type="str"), + zone_id=dict(type="str"), + domain=dict(type="str"), + domain_contains=dict(type="str"), + time_created_greater_than_or_equal_to=dict(type="str"), + time_created_less_than=dict(type="str"), + lifecycle_state=dict( + type="str", choices=["CREATING", "ACTIVE", "DELETING"] + ), + sort_by=dict( + type="str", choices=["displayName", "timeCreated", "domainName"] + ), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="steering_policy_attachment", + service_client_class=DnsClient, + namespace="dns", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(steering_policy_attachments=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_steering_policy_facts.py b/plugins/modules/oci_dns_steering_policy_facts.py new file mode 100644 index 0000000000..542f05071d --- /dev/null +++ b/plugins/modules/oci_dns_steering_policy_facts.py @@ -0,0 +1,585 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_steering_policy_facts +short_description: Fetches details about one or multiple SteeringPolicy resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple SteeringPolicy resources in Oracle Cloud Infrastructure + - Gets a list of all steering policies in the specified compartment. + - If I(steering_policy_id) is specified, the details of a single SteeringPolicy will be returned. +version_added: "2.5" +options: + steering_policy_id: + description: + - The OCID of the target steering policy. + - Required to get a specific steering_policy. + type: str + if_modified_since: + description: + - The `If-Modified-Since` header field makes a GET or HEAD request method + conditional on the selected representation's modification date being more + recent than the date provided in the field-value. Transfer of the + selected representation's data is avoided if that data has not changed. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + - Required to list multiple steering_policies. + type: str + display_name: + description: + - The displayName of a resource. + type: str + aliases: ["name"] + display_name_contains: + description: + - The partial displayName of a resource. Will match any resource whose name + (case-insensitive) contains the provided value. + type: str + health_check_monitor_id: + description: + - Search by health check monitor OCID. + Will match any resource whose health check monitor ID matches the provided value. + type: str + time_created_greater_than_or_equal_to: + description: + - An L(RFC 3339,https://www.ietf.org/rfc/rfc3339.txt) timestamp that states + all returned resources were created on or after the indicated time. + type: str + time_created_less_than: + description: + - An L(RFC 3339,https://www.ietf.org/rfc/rfc3339.txt) timestamp that states + all returned resources were created before the indicated time. + type: str + template: + description: + - Search by steering template type. + Will match any resource whose template type matches the provided value. + type: str + lifecycle_state: + description: + - The state of a resource. + type: str + choices: + - "ACTIVE" + - "CREATING" + - "DELETED" + - "DELETING" + sort_by: + description: + - The field by which to sort steering policies. If unspecified, defaults to `timeCreated`. + type: str + choices: + - "displayName" + - "timeCreated" + - "template" + sort_order: + description: + - The order to sort the resources. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List steering_policies + oci_dns_steering_policy_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific steering_policy + oci_dns_steering_policy_facts: + steering_policy_id: ocid1.steeringpolicy.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +steering_policies: + description: + - List of SteeringPolicy resources + returned: on success + type: complex + contains: + compartment_id: + description: + - The OCID of the compartment containing the steering policy. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - A user-friendly name for the steering policy. Does not have to be unique and can be changed. + Avoid entering confidential information. + returned: on success + type: string + sample: display_name_example + ttl: + description: + - The Time To Live (TTL) for responses from the steering policy, in seconds. + If not specified during creation, a value of 30 seconds will be used. + returned: on success + type: int + sample: 56 + health_check_monitor_id: + description: + - The OCID of the health check monitor providing health data about the answers of the + steering policy. A steering policy answer with `rdata` matching a monitored endpoint + will use the health data of that endpoint. A steering policy answer with `rdata` not + matching any monitored endpoint will be assumed healthy. + - "**Note:** To use the Health Check monitoring feature in a steering policy, a monitor + must be created using the Health Checks service first. For more information on how to + create a monitor, please see L(Managing Health + Checks,https://docs.cloud.oracle.com/iaas/Content/HealthChecks/Tasks/managinghealthchecks.htm)." + returned: on success + type: string + sample: ocid1.healthcheckmonitor.oc1..xxxxxxEXAMPLExxxxxx + template: + description: + - A set of predefined rules based on the desired purpose of the steering policy. Each + template utilizes Traffic Management's rules in a different order to produce the desired + results when answering DNS queries. + - "**Example:** The `FAILOVER` template determines answers by filtering the policy's answers + using the `FILTER` rule first, then the following rules in succession: `HEALTH`, `PRIORITY`, + and `LIMIT`. This gives the domain dynamic failover capability." + - "It is **strongly recommended** to use a template other than `CUSTOM` when creating + a steering policy." + - All templates require the rule order to begin with an unconditional `FILTER` rule that keeps + answers contingent upon `answer.isDisabled != true`, except for `CUSTOM`. A defined + `HEALTH` rule must follow the `FILTER` rule if the policy references a `healthCheckMonitorId`. + The last rule of a template must must be a `LIMIT` rule. For more information about templates + and code examples, see L(Traffic Management API + Guide,https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm). + - "**Template Types**" + - "* `FAILOVER` - Uses health check information on your endpoints to determine which DNS answers + to serve. If an endpoint fails a health check, the answer for that endpoint will be removed + from the list of available answers until the endpoint is detected as healthy." + - "* `LOAD_BALANCE` - Distributes web traffic to specified endpoints based on defined weights." + - "* `ROUTE_BY_GEO` - Answers DNS queries based on the query's geographic location. For a list of geographic + locations to route by, see L(Traffic Management Geographic + Locations,https://docs.cloud.oracle.com/iaas/Content/TrafficManagement/Reference/trafficmanagementgeo.htm)." + - "* `ROUTE_BY_ASN` - Answers DNS queries based on the query's originating ASN." + - "* `ROUTE_BY_IP` - Answers DNS queries based on the query's IP address." + - "* `CUSTOM` - Allows a customized configuration of rules." + returned: on success + type: string + sample: FAILOVER + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + answers: + description: + - The set of all answers that can potentially issue from the steering policy. + returned: on success + type: complex + contains: + name: + description: + - A user-friendly name for the answer, unique within the steering policy. + An answer's `name` property can be referenced in `answerCondition` properties + of rules using `answer.name`. + - "**Example:**" + - | + " \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.name == 'server 1'\\", + \\"shouldKeep\\": true + } + ] + } + ]" + returned: on success + type: string + sample: name_example + rtype: + description: + - The canonical name for the record's type. Only A, AAAA, and CNAME are supported. For more + information, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm). + returned: on success + type: string + sample: rtype_example + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm). + returned: on success + type: string + sample: rdata_example + pool: + description: + - "The freeform name of a group of one or more records in which this record is included, + such as \\"LAX data center\\". An answer's `pool` property can be referenced in `answerCondition` + properties of rules using `answer.pool`." + - "**Example:**" + - | + " \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.pool == 'US East Servers'\\", + \\"shouldKeep\\": true + } + ] + } + ]" + returned: on success + type: string + sample: pool_example + is_disabled: + description: + - Set this property to `true` to indicate that the answer is administratively disabled, + such as when the corresponding server is down for maintenance. An answer's `isDisabled` + property can be referenced in `answerCondition` properties in rules using `answer.isDisabled`. + - | + "**Example:** + \\"rules\\": [ + { + \\"ruleType\\": \\"FILTER\\", + \\"defaultAnswerData\\": [ + { + \\"answerCondition\\": \\"answer.isDisabled != true\\", + \\"shouldKeep\\": true + } + ] + }," + returned: on success + type: bool + sample: true + rules: + description: + - The series of rules that will be processed in sequence to reduce the pool of answers + to a response for any given request. + - The first rule receives a shuffled list of all answers, and every other rule receives + the list of answers emitted by the one preceding it. The last rule populates the + response. + returned: on success + type: complex + contains: + description: + description: + - A user-defined description of the rule's purpose or behavior. + returned: on success + type: string + sample: description_example + rule_type: + description: + - "The type of a rule determines its sorting/filtering behavior. + * `FILTER` - Filters the list of answers based on their defined boolean data. Answers remain + only if their `shouldKeep` value is `true`." + - "* `HEALTH` - Removes answers from the list if their `rdata` matches a target in the + health check monitor referenced by the steering policy and the target is reported down." + - "* `WEIGHTED` - Uses a number between 0 and 255 to determine how often an answer will be served + in relation to other answers. Anwers with a higher weight will be served more frequently." + - "* `PRIORITY` - Uses a defined rank value of answers to determine which answer to serve, + moving those with the lowest values to the beginning of the list without changing the + relative order of those with the same value. Answers can be given a value between `0` and `255`." + - "* `LIMIT` - Filters answers that are too far down the list. Parameter `defaultCount` + specifies how many answers to keep. **Example:** If `defaultCount` has a value of `2` and + there are five answers left, when the `LIMIT` rule is processed, only the first two answers + will remain in the list." + returned: on success + type: string + sample: FILTER + cases: + description: + - An array of `caseConditions`. A rule may optionally include a sequence of cases defining alternate + configurations for how it should behave during processing for any given DNS query. When a rule has + no sequence of `cases`, it is always evaluated with the same configuration during processing. When + a rule has an empty sequence of `cases`, it is always ignored during processing. When a rule has a + non-empty sequence of `cases`, its behavior during processing is configured by the first matching + `case` in the sequence. When a rule has no matching cases the rule is ignored. A rule case with no + `caseCondition` always matches. A rule case with a `caseCondition` matches only when that expression + evaluates to true for the given query. + returned: on success + type: complex + contains: + case_condition: + description: + - "An expression that uses conditions at the time of a DNS query to indicate + whether a case matches. Conditions may include the geographical location, IP + subnet, or ASN the DNS query originated. **Example:** If you have an + office that uses the subnet `192.0.2.0/24` you could use a `caseCondition` + expression `query.client.subnet in ('192.0.2.0/24')` to define a case that + matches queries from that office." + returned: on success + type: string + sample: query.client.address in (subnet '198.51.100.0/24') + answer_data: + description: + - An array of `SteeringPolicyFilterAnswerData` objects. + returned: on success + type: complex + contains: + answer_condition: + description: + - An expression that is used to select a set of answers that match a condition. For example, answers with matching pool + properties. + returned: on success + type: string + sample: answer.pool == 'A' + should_keep: + description: + - Keeps the answer only if the value is `true`. + returned: on success + type: bool + sample: true + default_answer_data: + description: + - Defines a default set of answer conditions and values that are applied to an answer when + `cases` is not defined for the rule, or a matching case does not have any matching + `answerCondition`s in its `answerData`. `defaultAnswerData` is not applied if `cases` is + defined and there are no matching cases. In this scenario, the next rule will be processed. + returned: on success + type: complex + contains: + answer_condition: + description: + - An expression that is used to select a set of answers that match a condition. For example, answers with matching pool + properties. + returned: on success + type: string + sample: answer.pool == 'A' + should_keep: + description: + - Keeps the answer only if the value is `true`. + returned: on success + type: bool + sample: true + default_count: + description: + - "Defines a default count if `cases` is not defined for the rule or a matching case does + not define `count`. `defaultCount` is **not** applied if `cases` is defined and there + are no matching cases. In this scenario, the next rule will be processed. If no rules + remain to be processed, the answer will be chosen from the remaining list of answers." + returned: on success + type: int + sample: 56 + _self: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + id: + description: + - The OCID of the resource. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + time_created: + description: + - The date and time the resource was created, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + lifecycle_state: + description: + - The current state of the resource. + returned: on success + type: string + sample: ACTIVE + sample: [{ + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "ttl": 56, + "health_check_monitor_id": "ocid1.healthcheckmonitor.oc1..xxxxxxEXAMPLExxxxxx", + "template": "FAILOVER", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "answers": [{ + "name": "name_example", + "rtype": "rtype_example", + "rdata": "rdata_example", + "pool": "pool_example", + "is_disabled": true + }], + "rules": [{ + "description": "description_example", + "rule_type": "FILTER", + "cases": [{ + "case_condition": "query.client.address in (subnet '198.51.100.0/24')", + "answer_data": [{ + "answer_condition": "answer.pool == 'A'", + "should_keep": true + }] + }], + "default_answer_data": [{ + "answer_condition": "answer.pool == 'A'", + "should_keep": true + }], + "default_count": 56 + }], + "_self": "_self_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "time_created": "2013-10-20T19:20:30+01:00", + "lifecycle_state": "ACTIVE" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SteeringPolicyFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "steering_policy_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + optional_get_method_params = [ + "if_modified_since", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_steering_policy, + steering_policy_id=self.module.params.get("steering_policy_id"), + **optional_kwargs + ) + + def list_resources(self): + optional_list_method_params = [ + "id", + "display_name", + "display_name_contains", + "health_check_monitor_id", + "time_created_greater_than_or_equal_to", + "time_created_less_than", + "template", + "lifecycle_state", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_steering_policies, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +SteeringPolicyFactsHelperCustom = get_custom_class("SteeringPolicyFactsHelperCustom") + + +class ResourceFactsHelper( + SteeringPolicyFactsHelperCustom, SteeringPolicyFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + steering_policy_id=dict(type="str"), + if_modified_since=dict(type="str"), + compartment_id=dict(type="str"), + display_name=dict(aliases=["name"], type="str"), + display_name_contains=dict(type="str"), + health_check_monitor_id=dict(type="str"), + time_created_greater_than_or_equal_to=dict(type="str"), + time_created_less_than=dict(type="str"), + template=dict(type="str"), + lifecycle_state=dict( + type="str", choices=["ACTIVE", "CREATING", "DELETED", "DELETING"] + ), + sort_by=dict( + type="str", choices=["displayName", "timeCreated", "template"] + ), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="steering_policy", + service_client_class=DnsClient, + namespace="dns", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(steering_policies=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_tsig_key.py b/plugins/modules/oci_dns_tsig_key.py new file mode 100644 index 0000000000..a7682e4488 --- /dev/null +++ b/plugins/modules/oci_dns_tsig_key.py @@ -0,0 +1,403 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_tsig_key +short_description: Manage a TsigKey resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a TsigKey resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new TSIG key in the specified compartment. There is no + `opc-retry-token` header since TSIG key names must be globally unique. +version_added: "2.9" +author: Oracle (@oracle) +options: + algorithm: + description: + - "TSIG key algorithms are encoded as domain names, but most consist of only one + non-empty label, which is not required to be explicitly absolute. + Applicable algorithms include: hmac-sha1, hmac-sha224, hmac-sha256, + hmac-sha512. For more information on these algorithms, see L(RFC 4635,https://tools.ietf.org/html/rfc4635#section-2)." + - Required for create using I(state=present). + type: str + name: + description: + - A globally unique domain name identifying the key for a given pair of hosts. + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + compartment_id: + description: + - The OCID of the compartment containing the TSIG key. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + secret: + description: + - A base64 string encoding the binary shared secret. + - Required for create using I(state=present). + type: str + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + tsig_key_id: + description: + - The OCID of the target TSIG key. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + if_unmodified_since: + description: + - The `If-Unmodified-Since` header field makes the request method + conditional on the selected representation's last modification date being + earlier than or equal to the date provided in the field-value. This + field accomplishes the same purpose as If-Match for cases where the user + agent does not have an entity-tag for the representation. + type: str + state: + description: + - The state of the TsigKey. + - Use I(state=present) to create or update a TsigKey. + - Use I(state=absent) to delete a TsigKey. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create tsig_key + oci_dns_tsig_key: + algorithm: algorithm_example + name: name_example + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + secret: secret_example + +- name: Update tsig_key using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_tsig_key: + name: name_example + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + if_unmodified_since: if_unmodified_since_example + +- name: Update tsig_key + oci_dns_tsig_key: + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + tsig_key_id: ocid1.tsigkey.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete tsig_key + oci_dns_tsig_key: + tsig_key_id: ocid1.tsigkey.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete tsig_key using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_tsig_key: + name: name_example + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +tsig_key: + description: + - Details of the TsigKey resource acted upon by the current operation + returned: on success + type: complex + contains: + algorithm: + description: + - "TSIG key algorithms are encoded as domain names, but most consist of only one + non-empty label, which is not required to be explicitly absolute. + Applicable algorithms include: hmac-sha1, hmac-sha224, hmac-sha256, + hmac-sha512. For more information on these algorithms, see L(RFC 4635,https://tools.ietf.org/html/rfc4635#section-2)." + returned: on success + type: string + sample: algorithm_example + name: + description: + - A globally unique domain name identifying the key for a given pair of hosts. + returned: on success + type: string + sample: name_example + compartment_id: + description: + - The OCID of the compartment containing the TSIG key. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + secret: + description: + - A base64 string encoding the binary shared secret. + returned: on success + type: string + sample: secret_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + id: + description: + - The OCID of the resource. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + _self: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + time_created: + description: + - The date and time the resource was created, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + lifecycle_state: + description: + - The current state of the resource. + returned: on success + type: string + sample: ACTIVE + time_updated: + description: + - The date and time the resource was last updated, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + sample: { + "algorithm": "algorithm_example", + "name": "name_example", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "secret": "secret_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "_self": "_self_example", + "time_created": "2013-10-20T19:20:30+01:00", + "lifecycle_state": "ACTIVE", + "time_updated": "2013-10-20T19:20:30+01:00" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + from oci.dns.models import CreateTsigKeyDetails + from oci.dns.models import UpdateTsigKeyDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class TsigKeyHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "tsig_key_id" + + def get_module_resource_id(self): + return self.module.params.get("tsig_key_id") + + def get_get_fn(self): + return self.client.get_tsig_key + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_tsig_key, tsig_key_id=self.module.params.get("tsig_key_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["name"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_tsig_keys, **kwargs) + + def get_create_model_class(self): + return CreateTsigKeyDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_tsig_key, + call_fn_args=(), + call_fn_kwargs=dict(create_tsig_key_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateTsigKeyDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_tsig_key, + call_fn_args=(), + call_fn_kwargs=dict( + tsig_key_id=self.module.params.get("tsig_key_id"), + update_tsig_key_details=update_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_tsig_key, + call_fn_args=(), + call_fn_kwargs=dict( + tsig_key_id=self.module.params.get("tsig_key_id"), + if_unmodified_since=self.module.params.get("if_unmodified_since"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +TsigKeyHelperCustom = get_custom_class("TsigKeyHelperCustom") + + +class ResourceHelper(TsigKeyHelperCustom, TsigKeyHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + algorithm=dict(type="str"), + name=dict(type="str"), + compartment_id=dict(type="str"), + secret=dict(type="str"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + tsig_key_id=dict(aliases=["id"], type="str"), + if_unmodified_since=dict(type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="tsig_key", + service_client_class=DnsClient, + namespace="dns", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_tsig_key_facts.py b/plugins/modules/oci_dns_tsig_key_facts.py new file mode 100644 index 0000000000..4a16333df0 --- /dev/null +++ b/plugins/modules/oci_dns_tsig_key_facts.py @@ -0,0 +1,299 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_tsig_key_facts +short_description: Fetches details about one or multiple TsigKey resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple TsigKey resources in Oracle Cloud Infrastructure + - Gets a list of all TSIG keys in the specified compartment. + - If I(tsig_key_id) is specified, the details of a single TsigKey will be returned. +version_added: "2.5" +options: + tsig_key_id: + description: + - The OCID of the target TSIG key. + - Required to get a specific tsig_key. + type: str + aliases: ["id"] + if_modified_since: + description: + - The `If-Modified-Since` header field makes a GET or HEAD request method + conditional on the selected representation's modification date being more + recent than the date provided in the field-value. Transfer of the + selected representation's data is avoided if that data has not changed. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + - Required to list multiple tsig_keys. + type: str + id: + description: + - The OCID of a resource. + type: str + name: + description: + - The name of a resource. + type: str + lifecycle_state: + description: + - The state of a resource. + type: str + choices: + - "ACTIVE" + - "CREATING" + sort_by: + description: + - The field by which to sort TSIG keys. If unspecified, defaults to `timeCreated`. + type: str + choices: + - "name" + - "timeCreated" + sort_order: + description: + - The order to sort the resources. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List tsig_keys + oci_dns_tsig_key_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific tsig_key + oci_dns_tsig_key_facts: + tsig_key_id: ocid1.tsigkey.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +tsig_keys: + description: + - List of TsigKey resources + returned: on success + type: complex + contains: + algorithm: + description: + - "TSIG key algorithms are encoded as domain names, but most consist of only one + non-empty label, which is not required to be explicitly absolute. + Applicable algorithms include: hmac-sha1, hmac-sha224, hmac-sha256, + hmac-sha512. For more information on these algorithms, see L(RFC 4635,https://tools.ietf.org/html/rfc4635#section-2)." + returned: on success + type: string + sample: algorithm_example + name: + description: + - A globally unique domain name identifying the key for a given pair of hosts. + returned: on success + type: string + sample: name_example + compartment_id: + description: + - The OCID of the compartment containing the TSIG key. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + secret: + description: + - A base64 string encoding the binary shared secret. + returned: on success + type: string + sample: secret_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + id: + description: + - The OCID of the resource. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + _self: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + time_created: + description: + - The date and time the resource was created, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + lifecycle_state: + description: + - The current state of the resource. + returned: on success + type: string + sample: ACTIVE + time_updated: + description: + - The date and time the resource was last updated, expressed in RFC 3339 timestamp format. + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + sample: [{ + "algorithm": "algorithm_example", + "name": "name_example", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "secret": "secret_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "_self": "_self_example", + "time_created": "2013-10-20T19:20:30+01:00", + "lifecycle_state": "ACTIVE", + "time_updated": "2013-10-20T19:20:30+01:00" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class TsigKeyFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "tsig_key_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + optional_get_method_params = [ + "if_modified_since", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_tsig_key, + tsig_key_id=self.module.params.get("tsig_key_id"), + **optional_kwargs + ) + + def list_resources(self): + optional_list_method_params = [ + "id", + "name", + "lifecycle_state", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_tsig_keys, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +TsigKeyFactsHelperCustom = get_custom_class("TsigKeyFactsHelperCustom") + + +class ResourceFactsHelper(TsigKeyFactsHelperCustom, TsigKeyFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + tsig_key_id=dict(aliases=["id"], type="str"), + if_modified_since=dict(type="str"), + compartment_id=dict(type="str"), + id=dict(type="str"), + name=dict(type="str"), + lifecycle_state=dict(type="str", choices=["ACTIVE", "CREATING"]), + sort_by=dict(type="str", choices=["name", "timeCreated"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="tsig_key", + service_client_class=DnsClient, + namespace="dns", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(tsig_keys=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_zone.py b/plugins/modules/oci_dns_zone.py new file mode 100644 index 0000000000..5c84967136 --- /dev/null +++ b/plugins/modules/oci_dns_zone.py @@ -0,0 +1,592 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_zone +short_description: Manage a Zone resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a Zone resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new zone in the specified compartment. The `compartmentId` + query parameter is required if the `Content-Type` header for the + request is `text/dns`. +version_added: "2.9" +author: Oracle (@oracle) +options: + migration_source: + description: + - Discriminator that is used to determine whether to create a new zone (NONE) or to migrate an existing DynECT zone (DYNECT). + type: str + choices: + - "NONE" + - "DYNECT" + default: "NONE" + name: + description: + - The name of the zone. + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + aliases: ["zone_name"] + compartment_id: + description: + - The OCID of the compartment containing the zone. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + zone_type: + description: + - The type of the zone. Must be either `PRIMARY` or `SECONDARY`. + - Applicable when migration_source is 'NONE' + type: str + choices: + - "PRIMARY" + - "SECONDARY" + external_masters: + description: + - External master servers for the zone. `externalMasters` becomes a + required parameter when the `zoneType` value is `SECONDARY`. + - Applicable when migration_source is 'NONE' + type: list + suboptions: + address: + description: + - The server's IP address (IPv4 or IPv6). + - Required when migration_source is 'NONE' + type: str + required: true + port: + description: + - The server's port. Port value must be a value of 53, otherwise omit + the port value. + - Applicable when migration_source is 'NONE' + type: int + tsig: + description: + - "" + - Applicable when migration_source is 'NONE' + type: dict + suboptions: + name: + description: + - A domain name identifying the key for a given pair of hosts. + - Required when migration_source is 'NONE' + type: str + required: true + secret: + description: + - A base64 string encoding the binary shared secret. + - Required when migration_source is 'NONE' + type: str + required: true + algorithm: + description: + - "TSIG Algorithms are encoded as domain names, but most consist of only one + non-empty label, which is not required to be explicitly absolute. + Applicable algorithms include: hmac-sha1, hmac-sha224, hmac-sha256, + hmac-sha512. For more information on these algorithms, see L(RFC 4635,https://tools.ietf.org/html/rfc4635#section-2)." + - Required when migration_source is 'NONE' + type: str + required: true + tsig_key_id: + description: + - The OCID of the TSIG key. + - Applicable when migration_source is 'NONE' + type: str + dynect_migration_details: + description: + - "" + - Applicable when migration_source is 'DYNECT' + type: dict + suboptions: + customer_name: + description: + - DynECT customer name the zone belongs to. + - Required when migration_source is 'DYNECT' + type: str + required: true + username: + description: + - DynECT API username to perform the migration with. + - Required when migration_source is 'DYNECT' + type: str + required: true + password: + description: + - DynECT API password for the provided username. + - Required when migration_source is 'DYNECT' + type: str + required: true + http_redirect_replacements: + description: + - A map of fully-qualified domain names (FQDNs) to an array of `MigrationReplacement` objects. + - Applicable when migration_source is 'DYNECT' + type: dict + zone_name_or_id: + description: + - The name or OCID of the target zone. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["zone_id", "id"] + if_unmodified_since: + description: + - The `If-Unmodified-Since` header field makes the request method + conditional on the selected representation's last modification date being + earlier than or equal to the date provided in the field-value. This + field accomplishes the same purpose as If-Match for cases where the user + agent does not have an entity-tag for the representation. + type: str + state: + description: + - The state of the Zone. + - Use I(state=present) to create or update a Zone. + - Use I(state=absent) to delete a Zone. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create zone + oci_dns_zone: + compartment_id: ocid1.compartment.oc1.. + name: example.com + zone_type: PRIMARY + +- name: Update zone using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_zone: + freeform_tags: '{''Department'': ''Finance''}' + +- name: Update zone + oci_dns_zone: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete zone + oci_dns_zone: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete zone using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_dns_zone: + name: example.com + compartment_id: ocid1.compartment.oc1.. + state: absent + +""" + +RETURN = """ +zone: + description: + - Details of the Zone resource acted upon by the current operation + returned: on success + type: complex + contains: + name: + description: + - The name of the zone. + returned: on success + type: string + sample: name_example + zone_type: + description: + - The type of the zone. Must be either `PRIMARY` or `SECONDARY`. + returned: on success + type: string + sample: PRIMARY + compartment_id: + description: + - The OCID of the compartment containing the zone. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + external_masters: + description: + - External master servers for the zone. `externalMasters` becomes a + required parameter when the `zoneType` value is `SECONDARY`. + returned: on success + type: complex + contains: + address: + description: + - The server's IP address (IPv4 or IPv6). + returned: on success + type: string + sample: address_example + port: + description: + - The server's port. Port value must be a value of 53, otherwise omit + the port value. + returned: on success + type: int + sample: 56 + tsig: + description: + - "" + returned: on success + type: complex + contains: + name: + description: + - A domain name identifying the key for a given pair of hosts. + returned: on success + type: string + sample: name_example + secret: + description: + - A base64 string encoding the binary shared secret. + returned: on success + type: string + sample: secret_example + algorithm: + description: + - "TSIG Algorithms are encoded as domain names, but most consist of only one + non-empty label, which is not required to be explicitly absolute. + Applicable algorithms include: hmac-sha1, hmac-sha224, hmac-sha256, + hmac-sha512. For more information on these algorithms, see L(RFC 4635,https://tools.ietf.org/html/rfc4635#section-2)." + returned: on success + type: string + sample: algorithm_example + tsig_key_id: + description: + - The OCID of the TSIG key. + returned: on success + type: string + sample: ocid1.tsigkey.oc1..xxxxxxEXAMPLExxxxxx + self_uri: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + id: + description: + - The OCID of the zone. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + time_created: + description: + - "The date and time the resource was created in \\"YYYY-MM-ddThh:mmZ\\" format + with a Z offset, as defined by RFC 3339." + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + version: + description: + - Version is the never-repeating, totally-orderable, version of the + zone, from which the serial field of the zone's SOA record is + derived. + returned: on success + type: string + sample: version_example + serial: + description: + - The current serial of the zone. As seen in the zone's SOA record. + returned: on success + type: int + sample: 56 + lifecycle_state: + description: + - The current state of the zone resource. + returned: on success + type: string + sample: ACTIVE + nameservers: + description: + - The authoritative nameservers for the zone. + returned: on success + type: complex + contains: + hostname: + description: + - The hostname of the nameserver. + returned: on success + type: string + sample: hostname_example + sample: { + "name": "name_example", + "zone_type": "PRIMARY", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "external_masters": [{ + "address": "address_example", + "port": 56, + "tsig": { + "name": "name_example", + "secret": "secret_example", + "algorithm": "algorithm_example" + }, + "tsig_key_id": "ocid1.tsigkey.oc1..xxxxxxEXAMPLExxxxxx" + }], + "self_uri": "_self_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "time_created": "2013-10-20T19:20:30+01:00", + "version": "version_example", + "serial": 56, + "lifecycle_state": "ACTIVE", + "nameservers": [{ + "hostname": "hostname_example" + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + from oci.dns.models import CreateZoneBaseDetails + from oci.dns.models import UpdateZoneDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ZoneHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "zone_name_or_id" + + def get_module_resource_id(self): + return self.module.params.get("zone_name_or_id") + + def get_get_fn(self): + return self.client.get_zone + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_zone, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["name", "zone_type"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_zones, **kwargs) + + def get_create_model_class(self): + return CreateZoneBaseDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_zone, + call_fn_args=(), + call_fn_kwargs=dict( + create_zone_details=create_details, + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateZoneDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_zone, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + update_zone_details=update_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_zone, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +ZoneHelperCustom = get_custom_class("ZoneHelperCustom") + + +class ResourceHelper(ZoneHelperCustom, ZoneHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + migration_source=dict( + type="str", default="NONE", choices=["NONE", "DYNECT"] + ), + name=dict(aliases=["zone_name"], type="str"), + compartment_id=dict(type="str"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + zone_type=dict(type="str", choices=["PRIMARY", "SECONDARY"]), + external_masters=dict( + type="list", + elements="dict", + options=dict( + address=dict(type="str", required=True), + port=dict(type="int"), + tsig=dict( + type="dict", + options=dict( + name=dict(type="str", required=True), + secret=dict(type="str", required=True), + algorithm=dict(type="str", required=True), + ), + ), + tsig_key_id=dict(type="str"), + ), + ), + dynect_migration_details=dict( + type="dict", + options=dict( + customer_name=dict(type="str", required=True), + username=dict(type="str", required=True), + password=dict(type="str", required=True, no_log=True), + http_redirect_replacements=dict(type="dict"), + ), + ), + zone_name_or_id=dict(aliases=["zone_id", "id"], type="str"), + if_unmodified_since=dict(type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="zone", + service_client_class=DnsClient, + namespace="dns", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_zone_facts.py b/plugins/modules/oci_dns_zone_facts.py new file mode 100644 index 0000000000..2acc44b6a6 --- /dev/null +++ b/plugins/modules/oci_dns_zone_facts.py @@ -0,0 +1,412 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_zone_facts +short_description: Fetches details about one or multiple Zone resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Zone resources in Oracle Cloud Infrastructure + - Gets a list of all zones in the specified compartment. The collection + can be filtered by name, time created, and zone type. + - If I(zone_name_or_id) is specified, the details of a single Zone will be returned. +version_added: "2.5" +options: + zone_name_or_id: + description: + - The name or OCID of the target zone. + - Required to get a specific zone. + type: str + aliases: ["zone_id", "id"] + if_modified_since: + description: + - The `If-Modified-Since` header field makes a GET or HEAD request method + conditional on the selected representation's modification date being more + recent than the date provided in the field-value. Transfer of the + selected representation's data is avoided if that data has not changed. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + - Required to list multiple zones. + type: str + name: + description: + - A case-sensitive filter for zone names. + Will match any zone with a name that equals the provided value. + type: str + aliases: ["zone_name"] + name_contains: + description: + - Search by zone name. + Will match any zone whose name (case-insensitive) contains the provided value. + type: str + zone_type: + description: + - Search by zone type, `PRIMARY` or `SECONDARY`. + Will match any zone whose type equals the provided value. + type: str + choices: + - "PRIMARY" + - "SECONDARY" + time_created_greater_than_or_equal_to: + description: + - An L(RFC 3339,https://www.ietf.org/rfc/rfc3339.txt) timestamp that states + all returned resources were created on or after the indicated time. + type: str + time_created_less_than: + description: + - An L(RFC 3339,https://www.ietf.org/rfc/rfc3339.txt) timestamp that states + all returned resources were created before the indicated time. + type: str + lifecycle_state: + description: + - The state of a resource. + type: str + choices: + - "ACTIVE" + - "CREATING" + - "DELETED" + - "DELETING" + - "FAILED" + sort_by: + description: + - The field by which to sort zones. + type: str + choices: + - "name" + - "zoneType" + - "timeCreated" + sort_order: + description: + - The order to sort the resources. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List zones + oci_dns_zone_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific zone + oci_dns_zone_facts: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +zones: + description: + - List of Zone resources + returned: on success + type: complex + contains: + name: + description: + - The name of the zone. + returned: on success + type: string + sample: name_example + zone_type: + description: + - The type of the zone. Must be either `PRIMARY` or `SECONDARY`. + returned: on success + type: string + sample: PRIMARY + compartment_id: + description: + - The OCID of the compartment containing the zone. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "**Example:** `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + external_masters: + description: + - External master servers for the zone. `externalMasters` becomes a + required parameter when the `zoneType` value is `SECONDARY`. + returned: on success + type: complex + contains: + address: + description: + - The server's IP address (IPv4 or IPv6). + returned: on success + type: string + sample: address_example + port: + description: + - The server's port. Port value must be a value of 53, otherwise omit + the port value. + returned: on success + type: int + sample: 56 + tsig: + description: + - "" + returned: on success + type: complex + contains: + name: + description: + - A domain name identifying the key for a given pair of hosts. + returned: on success + type: string + sample: name_example + secret: + description: + - A base64 string encoding the binary shared secret. + returned: on success + type: string + sample: secret_example + algorithm: + description: + - "TSIG Algorithms are encoded as domain names, but most consist of only one + non-empty label, which is not required to be explicitly absolute. + Applicable algorithms include: hmac-sha1, hmac-sha224, hmac-sha256, + hmac-sha512. For more information on these algorithms, see L(RFC 4635,https://tools.ietf.org/html/rfc4635#section-2)." + returned: on success + type: string + sample: algorithm_example + tsig_key_id: + description: + - The OCID of the TSIG key. + returned: on success + type: string + sample: ocid1.tsigkey.oc1..xxxxxxEXAMPLExxxxxx + self_uri: + description: + - The canonical absolute URL of the resource. + returned: on success + type: string + sample: _self_example + id: + description: + - The OCID of the zone. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + time_created: + description: + - "The date and time the resource was created in \\"YYYY-MM-ddThh:mmZ\\" format + with a Z offset, as defined by RFC 3339." + - "**Example:** `2016-07-22T17:23:59:60Z`" + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + version: + description: + - Version is the never-repeating, totally-orderable, version of the + zone, from which the serial field of the zone's SOA record is + derived. + returned: on success + type: string + sample: version_example + serial: + description: + - The current serial of the zone. As seen in the zone's SOA record. + returned: on success + type: int + sample: 56 + lifecycle_state: + description: + - The current state of the zone resource. + returned: on success + type: string + sample: ACTIVE + nameservers: + description: + - The authoritative nameservers for the zone. + returned: on success + type: complex + contains: + hostname: + description: + - The hostname of the nameserver. + returned: on success + type: string + sample: hostname_example + sample: [{ + "name": "name_example", + "zone_type": "PRIMARY", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "external_masters": [{ + "address": "address_example", + "port": 56, + "tsig": { + "name": "name_example", + "secret": "secret_example", + "algorithm": "algorithm_example" + }, + "tsig_key_id": "ocid1.tsigkey.oc1..xxxxxxEXAMPLExxxxxx" + }], + "self_uri": "_self_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "time_created": "2013-10-20T19:20:30+01:00", + "version": "version_example", + "serial": 56, + "lifecycle_state": "ACTIVE", + "nameservers": [{ + "hostname": "hostname_example" + }] + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ZoneFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "zone_name_or_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + optional_get_method_params = [ + "if_modified_since", + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_zone, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + **optional_kwargs + ) + + def list_resources(self): + optional_list_method_params = [ + "name", + "name_contains", + "zone_type", + "time_created_greater_than_or_equal_to", + "time_created_less_than", + "lifecycle_state", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_zones, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +ZoneFactsHelperCustom = get_custom_class("ZoneFactsHelperCustom") + + +class ResourceFactsHelper(ZoneFactsHelperCustom, ZoneFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + zone_name_or_id=dict(aliases=["zone_id", "id"], type="str"), + if_modified_since=dict(type="str"), + compartment_id=dict(type="str"), + name=dict(aliases=["zone_name"], type="str"), + name_contains=dict(type="str"), + zone_type=dict(type="str", choices=["PRIMARY", "SECONDARY"]), + time_created_greater_than_or_equal_to=dict(type="str"), + time_created_less_than=dict(type="str"), + lifecycle_state=dict( + type="str", + choices=["ACTIVE", "CREATING", "DELETED", "DELETING", "FAILED"], + ), + sort_by=dict(type="str", choices=["name", "zoneType", "timeCreated"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="zone", + service_client_class=DnsClient, + namespace="dns", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(zones=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_zone_records.py b/plugins/modules/oci_dns_zone_records.py new file mode 100644 index 0000000000..d1abec1f22 --- /dev/null +++ b/plugins/modules/oci_dns_zone_records.py @@ -0,0 +1,401 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_zone_records +short_description: Manage a ZoneRecords resource in Oracle Cloud Infrastructure +description: + - This module allows the user to update and patch a ZoneRecords resource in Oracle Cloud Infrastructure + - This module does not support check mode +version_added: "2.9" +author: Oracle (@oracle) +options: + zone_name_or_id: + description: + - The name or OCID of the target zone. + type: str + aliases: ["zone_id", "name", "zone_name", "id"] + required: true + update_items: + description: + - "" + type: list + suboptions: + domain: + description: + - The fully qualified domain name where the record can be located. + type: str + required: true + record_hash: + description: + - A unique identifier for the record within its zone. + type: str + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + type: bool + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + type: str + required: true + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + type: str + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + type: str + required: true + ttl: + description: + - The Time To Live for the record, in seconds. + type: int + required: true + if_unmodified_since: + description: + - The `If-Unmodified-Since` header field makes the request method + conditional on the selected representation's last modification date being + earlier than or equal to the date provided in the field-value. This + field accomplishes the same purpose as If-Match for cases where the user + agent does not have an entity-tag for the representation. + type: str + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + type: str + patch_items: + description: + - "" + type: list + suboptions: + domain: + description: + - The fully qualified domain name where the record can be located. + type: str + record_hash: + description: + - A unique identifier for the record within its zone. + type: str + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + type: bool + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + type: str + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + type: str + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + type: str + ttl: + description: + - The Time To Live for the record, in seconds. + type: int + operation: + description: + - A description of how a record relates to a PATCH operation. + - "- `REQUIRE` indicates a precondition that record data **must** already exist. + - `PROHIBIT` indicates a precondition that record data **must not** already exist. + - `ADD` indicates that record data **must** exist after successful application. + - `REMOVE` indicates that record data **must not** exist after successful application." + - " **Note:** `ADD` and `REMOVE` operations can succeed even if + they require no changes when applied, such as when the described + records are already present or absent." + - " **Note:** `ADD` and `REMOVE` operations can describe changes for + more than one record." + - " **Example:** `{ \\"domain\\": \\"www.example.com\\", \\"rtype\\": \\"AAAA\\", \\"ttl\\": 60 }` + specifies a new TTL for every record in the www.example.com AAAA RRSet." + type: str + choices: + - "REQUIRE" + - "PROHIBIT" + - "ADD" + - "REMOVE" + state: + description: + - The state of the ZoneRecords. + - Use I(state=present) to update an existing a ZoneRecords. + type: str + required: false + default: 'present' + choices: ["present"] +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Update zone_records + oci_dns_zone_records: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + update_items: + - domain: domain_example + rdata: rdata_example + rtype: rtype_example + ttl: 56 + +""" + +RETURN = """ +zone_records: + description: + - Details of the ZoneRecords resource acted upon by the current operation + returned: on success + type: complex + contains: + domain: + description: + - The fully qualified domain name where the record can be located. + returned: on success + type: string + sample: domain_example + record_hash: + description: + - A unique identifier for the record within its zone. + returned: on success + type: string + sample: record_hash_example + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + returned: on success + type: bool + sample: true + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + returned: on success + type: string + sample: rdata_example + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + returned: on success + type: string + sample: rrset_version_example + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + returned: on success + type: string + sample: rtype_example + ttl: + description: + - The Time To Live for the record, in seconds. + returned: on success + type: int + sample: 56 + sample: { + "domain": "domain_example", + "record_hash": "record_hash_example", + "is_protected": true, + "rdata": "rdata_example", + "rrset_version": "rrset_version_example", + "rtype": "rtype_example", + "ttl": 56 + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + from oci.dns.models import UpdateZoneRecordsDetails + from oci.dns.models import PatchZoneRecordsDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ZoneRecordsHelperGen(OCIResourceHelperBase): + """Supported operations: update, patch and get""" + + def get_module_resource_id_param(self): + return "zone_name_or_id" + + def get_module_resource_id(self): + return self.module.params.get("zone_name_or_id") + + def get_get_fn(self): + return self.client.get_zone_records + + def get_resource(self): + return oci_common_utils.get_default_response_from_resource( + oci_common_utils.list_all_resources( + self.client.get_zone_records, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + ).items + ) + + def get_update_model_class(self): + return UpdateZoneRecordsDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_zone_records, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + update_zone_records_details=update_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_patch_model_class(self): + return PatchZoneRecordsDetails + + def patch_resource(self): + patch_details = self.get_patch_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.patch_zone_records, + call_fn_args=(), + call_fn_kwargs=dict( + zone_name_or_id=self.module.params.get("zone_name_or_id"), + patch_zone_records_details=patch_details, + if_unmodified_since=self.module.params.get("if_unmodified_since"), + compartment_id=self.module.params.get("compartment_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.PATCH_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +ZoneRecordsHelperCustom = get_custom_class("ZoneRecordsHelperCustom") + + +class ResourceHelper(ZoneRecordsHelperCustom, ZoneRecordsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + zone_name_or_id=dict( + aliases=["zone_id", "name", "zone_name", "id"], + type="str", + required=True, + ), + update_items=dict( + type="list", + elements="dict", + options=dict( + domain=dict(type="str", required=True), + record_hash=dict(type="str"), + is_protected=dict(type="bool"), + rdata=dict(type="str", required=True), + rrset_version=dict(type="str"), + rtype=dict(type="str", required=True), + ttl=dict(type="int", required=True), + ), + ), + if_unmodified_since=dict(type="str"), + compartment_id=dict(type="str"), + patch_items=dict( + type="list", + elements="dict", + options=dict( + domain=dict(type="str"), + record_hash=dict(type="str"), + is_protected=dict(type="bool"), + rdata=dict(type="str"), + rrset_version=dict(type="str"), + rtype=dict(type="str"), + ttl=dict(type="int"), + operation=dict( + type="str", choices=["REQUIRE", "PROHIBIT", "ADD", "REMOVE"] + ), + ), + ), + state=dict(type="str", default="present", choices=["present"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="zone_records", + service_client_class=DnsClient, + namespace="dns", + ) + + result = dict(changed=False) + + if resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_patch(): + result = resource_helper.patch() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_dns_zone_records_facts.py b/plugins/modules/oci_dns_zone_records_facts.py new file mode 100644 index 0000000000..56aa3a9c8b --- /dev/null +++ b/plugins/modules/oci_dns_zone_records_facts.py @@ -0,0 +1,261 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_dns_zone_records_facts +short_description: Fetches details about a ZoneRecords resource in Oracle Cloud Infrastructure +description: + - Fetches details about a ZoneRecords resource in Oracle Cloud Infrastructure + - Gets all records in the specified zone. The results are + sorted by `domain` in alphabetical order by default. For more + information about records, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). +version_added: "2.5" +options: + zone_name_or_id: + description: + - The name or OCID of the target zone. + type: str + aliases: ["zone_id", "name", "zone_name", "id"] + required: true + if_modified_since: + description: + - The `If-Modified-Since` header field makes a GET or HEAD request method + conditional on the selected representation's modification date being more + recent than the date provided in the field-value. Transfer of the + selected representation's data is avoided if that data has not changed. + type: str + zone_version: + description: + - The version of the zone for which data is requested. + type: str + domain: + description: + - Search by domain. + Will match any record whose domain (case-insensitive) equals the provided value. + type: str + domain_contains: + description: + - Search by domain. + Will match any record whose domain (case-insensitive) contains the provided value. + type: str + rtype: + description: + - Search by record type. + Will match any record whose L(type,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4) (case-insensitive) + equals the provided value. + type: str + sort_by: + description: + - The field by which to sort records. + type: str + choices: + - "domain" + - "rtype" + - "ttl" + sort_order: + description: + - The order to sort the resources. + type: str + choices: + - "ASC" + - "DESC" + compartment_id: + description: + - The OCID of the compartment the resource belongs to. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific zone_records + oci_dns_zone_records_facts: + zone_name_or_id: ocid1.zonenameor.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +zone_records: + description: + - ZoneRecords resource + returned: on success + type: complex + contains: + domain: + description: + - The fully qualified domain name where the record can be located. + returned: on success + type: string + sample: domain_example + record_hash: + description: + - A unique identifier for the record within its zone. + returned: on success + type: string + sample: record_hash_example + is_protected: + description: + - A Boolean flag indicating whether or not parts of the record + are unable to be explicitly managed. + returned: on success + type: bool + sample: true + rdata: + description: + - The record's data, as whitespace-delimited tokens in + type-specific presentation format. All RDATA is normalized and the + returned presentation of your RDATA may differ from its initial input. + For more information about RDATA, see L(Supported DNS Resource Record + Types,https://docs.cloud.oracle.com/iaas/Content/DNS/Reference/supporteddnsresource.htm) + returned: on success + type: string + sample: rdata_example + rrset_version: + description: + - The latest version of the record's zone in which its RRSet differs + from the preceding version. + returned: on success + type: string + sample: rrset_version_example + rtype: + description: + - The canonical name for the record's type, such as A or CNAME. For more + information, see L(Resource Record (RR) TYPEs,https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4). + returned: on success + type: string + sample: rtype_example + ttl: + description: + - The Time To Live for the record, in seconds. + returned: on success + type: int + sample: 56 + sample: { + "domain": "domain_example", + "record_hash": "record_hash_example", + "is_protected": true, + "rdata": "rdata_example", + "rrset_version": "rrset_version_example", + "rtype": "rtype_example", + "ttl": 56 + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.dns import DnsClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ZoneRecordsFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "zone_name_or_id", + ] + + def get_resource(self): + optional_get_method_params = [ + "if_modified_since", + "zone_version", + "domain", + "domain_contains", + "rtype", + "sort_by", + "sort_order", + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.get_default_response_from_resource( + oci_common_utils.list_all_resources( + self.client.get_zone_records, + zone_name_or_id=self.module.params.get("zone_name_or_id"), + **optional_kwargs + ).items + ) + + +ZoneRecordsFactsHelperCustom = get_custom_class("ZoneRecordsFactsHelperCustom") + + +class ResourceFactsHelper(ZoneRecordsFactsHelperCustom, ZoneRecordsFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + zone_name_or_id=dict( + aliases=["zone_id", "name", "zone_name", "id"], + type="str", + required=True, + ), + if_modified_since=dict(type="str"), + zone_version=dict(type="str"), + domain=dict(type="str"), + domain_contains=dict(type="str"), + rtype=dict(type="str"), + sort_by=dict(type="str", choices=["domain", "rtype", "ttl"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + compartment_id=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="zone_records", + service_client_class=DnsClient, + namespace="dns", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(zone_records=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_email_sender.py b/plugins/modules/oci_email_sender.py new file mode 100644 index 0000000000..aa7a6d72fd --- /dev/null +++ b/plugins/modules/oci_email_sender.py @@ -0,0 +1,327 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_email_sender +short_description: Manage a Sender resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a Sender resource in Oracle Cloud Infrastructure + - For I(state=present), creates a sender for a tenancy in a given compartment. +version_added: "2.9" +author: Oracle (@oracle) +options: + compartment_id: + description: + - The OCID of the compartment that contains the sender. + - Required for create using I(state=present). + type: str + email_address: + description: + - The email address of the sender. + - Required for create using I(state=present). + type: str + freeform_tags: + description: + - "Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - "Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + sender_id: + description: + - The unique OCID of the sender. + - Required for update using I(state=present). + - Required for delete using I(state=absent). + type: str + aliases: ["id"] + state: + description: + - The state of the Sender. + - Use I(state=present) to create or update a Sender. + - Use I(state=absent) to delete a Sender. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create sender + oci_email_sender: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + email_address: email_address_example + +- name: Update sender + oci_email_sender: + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + sender_id: ocid1.sender.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete sender + oci_email_sender: + sender_id: ocid1.sender.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +sender: + description: + - Details of the Sender resource acted upon by the current operation + returned: on success + type: complex + contains: + compartment_id: + description: + - The OCID for the compartment. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + email_address: + description: + - Email address of the sender. + returned: on success + type: string + sample: email_address_example + id: + description: + - The unique OCID of the sender. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + is_spf: + description: + - Value of the SPF field. For more information about SPF, please see + L(SPF Authentication,https://docs.us-phoenix-1.oraclecloud.com/Content/Email/Concepts/overview.htm#components). + returned: on success + type: bool + sample: true + lifecycle_state: + description: + - The sender's current lifecycle state. + returned: on success + type: string + sample: CREATING + time_created: + description: + - "The date and time the approved sender was added in \\"YYYY-MM-ddThh:mmZ\\" + format with a Z offset, as defined by RFC 3339." + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + freeform_tags: + description: + - "Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - "Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: { + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "email_address": "email_address_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "is_spf": true, + "lifecycle_state": "CREATING", + "time_created": "2013-10-20T19:20:30+01:00", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.email import EmailClient + from oci.email.models import CreateSenderDetails + from oci.email.models import UpdateSenderDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SenderHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "sender_id" + + def get_module_resource_id(self): + return self.module.params.get("sender_id") + + def get_get_fn(self): + return self.client.get_sender + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_sender, sender_id=self.module.params.get("sender_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["email_address"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_senders, **kwargs) + + def get_create_model_class(self): + return CreateSenderDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_sender, + call_fn_args=(), + call_fn_kwargs=dict(create_sender_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateSenderDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_sender, + call_fn_args=(), + call_fn_kwargs=dict( + sender_id=self.module.params.get("sender_id"), + update_sender_details=update_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_sender, + call_fn_args=(), + call_fn_kwargs=dict(sender_id=self.module.params.get("sender_id"),), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +SenderHelperCustom = get_custom_class("SenderHelperCustom") + + +class ResourceHelper(SenderHelperCustom, SenderHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + compartment_id=dict(type="str"), + email_address=dict(type="str"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + sender_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="sender", + service_client_class=EmailClient, + namespace="email", + ) + + result = dict(changed=False) + + if resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_email_sender_facts.py b/plugins/modules/oci_email_sender_facts.py new file mode 100644 index 0000000000..50e3695eb2 --- /dev/null +++ b/plugins/modules/oci_email_sender_facts.py @@ -0,0 +1,258 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_email_sender_facts +short_description: Fetches details about one or multiple Sender resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Sender resources in Oracle Cloud Infrastructure + - Gets a collection of approved sender email addresses and sender IDs. + - If I(sender_id) is specified, the details of a single Sender will be returned. +version_added: "2.5" +options: + sender_id: + description: + - The unique OCID of the sender. + - Required to get a specific sender. + type: str + aliases: ["id"] + compartment_id: + description: + - The OCID for the compartment. + - Required to list multiple senders. + type: str + lifecycle_state: + description: + - The current state of a sender. + type: str + choices: + - "CREATING" + - "ACTIVE" + - "DELETING" + - "DELETED" + email_address: + description: + - The email address of the approved sender. + type: str + sort_by: + description: + - The field to sort by. The `TIMECREATED` value returns the list in in + descending order by default. The `EMAILADDRESS` value returns the list in + ascending order by default. Use the `SortOrderQueryParam` to change the + direction of the returned list of items. + type: str + choices: + - "TIMECREATED" + - "EMAILADDRESS" + sort_order: + description: + - The sort order to use, either ascending or descending order. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List senders + oci_email_sender_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific sender + oci_email_sender_facts: + sender_id: ocid1.sender.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +senders: + description: + - List of Sender resources + returned: on success + type: complex + contains: + compartment_id: + description: + - The OCID for the compartment. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + email_address: + description: + - Email address of the sender. + returned: on success + type: string + sample: email_address_example + id: + description: + - The unique OCID of the sender. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + is_spf: + description: + - Value of the SPF field. For more information about SPF, please see + L(SPF Authentication,https://docs.us-phoenix-1.oraclecloud.com/Content/Email/Concepts/overview.htm#components). + returned: on success + type: bool + sample: true + lifecycle_state: + description: + - The sender's current lifecycle state. + returned: on success + type: string + sample: CREATING + time_created: + description: + - "The date and time the approved sender was added in \\"YYYY-MM-ddThh:mmZ\\" + format with a Z offset, as defined by RFC 3339." + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + freeform_tags: + description: + - "Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - "Defined tags for this resource. Each key is predefined and scoped to a namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: [{ + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "email_address": "email_address_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "is_spf": true, + "lifecycle_state": "CREATING", + "time_created": "2013-10-20T19:20:30+01:00", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.email import EmailClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SenderFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "sender_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_sender, sender_id=self.module.params.get("sender_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "lifecycle_state", + "email_address", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_senders, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +SenderFactsHelperCustom = get_custom_class("SenderFactsHelperCustom") + + +class ResourceFactsHelper(SenderFactsHelperCustom, SenderFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + sender_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + lifecycle_state=dict( + type="str", choices=["CREATING", "ACTIVE", "DELETING", "DELETED"] + ), + email_address=dict(type="str"), + sort_by=dict(type="str", choices=["TIMECREATED", "EMAILADDRESS"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="sender", + service_client_class=EmailClient, + namespace="email", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(senders=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_email_suppression.py b/plugins/modules/oci_email_suppression.py new file mode 100644 index 0000000000..146e8c0a2b --- /dev/null +++ b/plugins/modules/oci_email_suppression.py @@ -0,0 +1,271 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_email_suppression +short_description: Manage a Suppression resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create and delete a Suppression resource in Oracle Cloud Infrastructure + - "For I(state=present), adds recipient email addresses to the suppression list for a tenancy. + Addresses added to the suppression list via the API are denoted as + \\"MANUAL\\" in the `reason` field. *Note:* All email addresses added to the + suppression list are normalized to include only lowercase letters." +version_added: "2.9" +author: Oracle (@oracle) +options: + compartment_id: + description: + - The OCID of the compartment to contain the suppression. Since + suppressions are at the customer level, this must be the tenancy + OCID. + - Required for create using I(state=present). + type: str + email_address: + description: + - The recipient email address of the suppression. + - Required for create using I(state=present). + type: str + suppression_id: + description: + - The unique OCID of the suppression. + - Required for delete using I(state=absent). + type: str + aliases: ["id"] + state: + description: + - The state of the Suppression. + - Use I(state=present) to create a Suppression. + - Use I(state=absent) to delete a Suppression. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] +""" + +EXAMPLES = """ +- name: Create suppression + oci_email_suppression: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + email_address: email_address_example + +- name: Delete suppression + oci_email_suppression: + suppression_id: ocid1.suppression.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +suppression: + description: + - Details of the Suppression resource acted upon by the current operation + returned: on success + type: complex + contains: + compartment_id: + description: + - The OCID of the compartment to contain the suppression. Since + suppressions are at the customer level, this must be the tenancy + OCID. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + email_address: + description: + - Email address of the suppression. + returned: on success + type: string + sample: email_address_example + id: + description: + - The unique ID of the suppression. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + reason: + description: + - The reason that the email address was suppressed. For more information on the types of bounces, see L(Suppression List,https://docs.us- + phoenix-1.oraclecloud.com/Content/Email/Concepts/overview.htm#components). + returned: on success + type: string + sample: UNKNOWN + time_created: + description: + - "The date and time the suppression was added in \\"YYYY-MM-ddThh:mmZ\\" + format with a Z offset, as defined by RFC 3339." + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + sample: { + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "email_address": "email_address_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "reason": "UNKNOWN", + "time_created": "2013-10-20T19:20:30+01:00" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.email import EmailClient + from oci.email.models import CreateSuppressionDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SuppressionHelperGen(OCIResourceHelperBase): + """Supported operations: create, get, list and delete""" + + def get_module_resource_id_param(self): + return "suppression_id" + + def get_module_resource_id(self): + return self.module.params.get("suppression_id") + + def get_get_fn(self): + return self.client.get_suppression + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_suppression, + suppression_id=self.module.params.get("suppression_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["email_address"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_suppressions, **kwargs + ) + + def get_create_model_class(self): + return CreateSuppressionDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_suppression, + call_fn_args=(), + call_fn_kwargs=dict(create_suppression_details=create_details,), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_suppression, + call_fn_args=(), + call_fn_kwargs=dict( + suppression_id=self.module.params.get("suppression_id"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +SuppressionHelperCustom = get_custom_class("SuppressionHelperCustom") + + +class ResourceHelper(SuppressionHelperCustom, SuppressionHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=False + ) + module_args.update( + dict( + compartment_id=dict(type="str"), + email_address=dict(type="str"), + suppression_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="suppression", + service_client_class=EmailClient, + namespace="email", + ) + + result = dict(changed=False) + + if resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_email_suppression_facts.py b/plugins/modules/oci_email_suppression_facts.py new file mode 100644 index 0000000000..d655ce9b03 --- /dev/null +++ b/plugins/modules/oci_email_suppression_facts.py @@ -0,0 +1,249 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_email_suppression_facts +short_description: Fetches details about one or multiple Suppression resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Suppression resources in Oracle Cloud Infrastructure + - Gets a list of suppressed recipient email addresses for a user. The + `compartmentId` for suppressions must be a tenancy OCID. The returned list + is sorted by creation time in descending order. + - If I(suppression_id) is specified, the details of a single Suppression will be returned. +version_added: "2.5" +options: + suppression_id: + description: + - The unique OCID of the suppression. + - Required to get a specific suppression. + type: str + aliases: ["id"] + compartment_id: + description: + - The OCID for the compartment. + - Required to list multiple suppressions. + type: str + email_address: + description: + - The email address of the suppression. + type: str + time_created_greater_than_or_equal_to: + description: + - "Search for suppressions that were created within a specific date range, + using this parameter to specify the earliest creation date for the + returned list (inclusive). Specifying this parameter without the + corresponding `timeCreatedLessThan` parameter will retrieve suppressions created from the + given `timeCreatedGreaterThanOrEqualTo` to the current time, in \\"YYYY-MM-ddThh:mmZ\\" format with a + Z offset, as defined by RFC 3339." + - "**Example:** 2016-12-19T16:39:57.600Z" + type: str + time_created_less_than: + description: + - "Search for suppressions that were created within a specific date range, + using this parameter to specify the latest creation date for the returned + list (exclusive). Specifying this parameter without the corresponding + `timeCreatedGreaterThanOrEqualTo` parameter will retrieve all suppressions created before the + specified end date, in \\"YYYY-MM-ddThh:mmZ\\" format with a Z offset, as + defined by RFC 3339." + - "**Example:** 2016-12-19T16:39:57.600Z" + type: str + sort_by: + description: + - The field to sort by. The `TIMECREATED` value returns the list in in + descending order by default. The `EMAILADDRESS` value returns the list in + ascending order by default. Use the `SortOrderQueryParam` to change the + direction of the returned list of items. + type: str + choices: + - "TIMECREATED" + - "EMAILADDRESS" + sort_order: + description: + - The sort order to use, either ascending or descending order. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List suppressions + oci_email_suppression_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific suppression + oci_email_suppression_facts: + suppression_id: ocid1.suppression.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +suppressions: + description: + - List of Suppression resources + returned: on success + type: complex + contains: + compartment_id: + description: + - The OCID of the compartment to contain the suppression. Since + suppressions are at the customer level, this must be the tenancy + OCID. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + email_address: + description: + - Email address of the suppression. + returned: on success + type: string + sample: email_address_example + id: + description: + - The unique ID of the suppression. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + reason: + description: + - The reason that the email address was suppressed. For more information on the types of bounces, see L(Suppression List,https://docs.us- + phoenix-1.oraclecloud.com/Content/Email/Concepts/overview.htm#components). + returned: on success + type: string + sample: UNKNOWN + time_created: + description: + - "The date and time the suppression was added in \\"YYYY-MM-ddThh:mmZ\\" + format with a Z offset, as defined by RFC 3339." + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + sample: [{ + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "email_address": "email_address_example", + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "reason": "UNKNOWN", + "time_created": "2013-10-20T19:20:30+01:00" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.email import EmailClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SuppressionFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "suppression_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_suppression, + suppression_id=self.module.params.get("suppression_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "email_address", + "time_created_greater_than_or_equal_to", + "time_created_less_than", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_suppressions, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +SuppressionFactsHelperCustom = get_custom_class("SuppressionFactsHelperCustom") + + +class ResourceFactsHelper(SuppressionFactsHelperCustom, SuppressionFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + suppression_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + email_address=dict(type="str"), + time_created_greater_than_or_equal_to=dict(type="str"), + time_created_less_than=dict(type="str"), + sort_by=dict(type="str", choices=["TIMECREATED", "EMAILADDRESS"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="suppression", + service_client_class=EmailClient, + namespace="email", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(suppressions=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_file_storage_export.py b/plugins/modules/oci_file_storage_export.py index 2caf13f1f4..ebc8643e56 100644 --- a/plugins/modules/oci_file_storage_export.py +++ b/plugins/modules/oci_file_storage_export.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete an Export resource in Oracle Cloud Infrastructure - For I(state=present), creates a new export in the specified export set, path, and file system. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: export_options: description: @@ -131,10 +132,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -338,30 +335,30 @@ def get_resource(self): self.client.get_export, export_id=self.module.params.get("export_id"), ) - def list_resources(self): - required_list_method_params = [] - - optional_list_method_params = [ - "export_set_id", - "file_system_id", - ] + def get_required_kwargs_for_list(self): + return dict() - required_kwargs = dict( - (param, self.module.params[param]) for param in required_list_method_params - ) + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["export_set_id", "file_system_id"] - optional_kwargs = dict( + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_exports, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_file_storage_export_facts.py b/plugins/modules/oci_file_storage_export_facts.py index 11cd46c9f0..bb697a2ca2 100644 --- a/plugins/modules/oci_file_storage_export_facts.py +++ b/plugins/modules/oci_file_storage_export_facts.py @@ -82,10 +82,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_file_storage_export_set.py b/plugins/modules/oci_file_storage_export_set.py index 47f748f931..e2589915a5 100644 --- a/plugins/modules/oci_file_storage_export_set.py +++ b/plugins/modules/oci_file_storage_export_set.py @@ -23,7 +23,8 @@ short_description: Manage an ExportSet resource in Oracle Cloud Infrastructure description: - This module allows the user to update an ExportSet resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: export_set_id: description: @@ -82,10 +83,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ @@ -233,32 +230,37 @@ def get_resource(self): export_set_id=self.module.params.get("export_set_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "availability_domain", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_export_sets, **kwargs ) diff --git a/plugins/modules/oci_file_storage_export_set_facts.py b/plugins/modules/oci_file_storage_export_set_facts.py index 5aaeafca67..f13b7cc9be 100644 --- a/plugins/modules/oci_file_storage_export_set_facts.py +++ b/plugins/modules/oci_file_storage_export_set_facts.py @@ -85,10 +85,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_file_storage_file_system.py b/plugins/modules/oci_file_storage_file_system.py index 44b3f4ea5d..d996d72b21 100644 --- a/plugins/modules/oci_file_storage_file_system.py +++ b/plugins/modules/oci_file_storage_file_system.py @@ -45,7 +45,8 @@ find its OCID in the response. You can also retrieve a resource's OCID by using a List API operation on that resource type or by viewing the resource in the Console. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -99,10 +100,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -267,32 +264,37 @@ def get_resource(self): file_system_id=self.module.params.get("file_system_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "availability_domain", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_file_systems, **kwargs ) diff --git a/plugins/modules/oci_file_storage_file_system_facts.py b/plugins/modules/oci_file_storage_file_system_facts.py index c498e9833f..240c076419 100644 --- a/plugins/modules/oci_file_storage_file_system_facts.py +++ b/plugins/modules/oci_file_storage_file_system_facts.py @@ -85,10 +85,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_file_storage_mount_target.py b/plugins/modules/oci_file_storage_mount_target.py index fd9d0786a4..673d342439 100644 --- a/plugins/modules/oci_file_storage_mount_target.py +++ b/plugins/modules/oci_file_storage_mount_target.py @@ -51,7 +51,8 @@ you can find its OCID in the response. You can also retrieve a resource's OCID by using a List API operation on that resource type, or by viewing the resource in the Console. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -130,10 +131,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -313,32 +310,37 @@ def get_resource(self): mount_target_id=self.module.params.get("mount_target_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "availability_domain", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_mount_targets, **kwargs ) diff --git a/plugins/modules/oci_file_storage_mount_target_facts.py b/plugins/modules/oci_file_storage_mount_target_facts.py index efbbc81423..5521006da1 100644 --- a/plugins/modules/oci_file_storage_mount_target_facts.py +++ b/plugins/modules/oci_file_storage_mount_target_facts.py @@ -89,10 +89,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_file_storage_snapshot.py b/plugins/modules/oci_file_storage_snapshot.py index 409c6990a9..d93c2586ab 100644 --- a/plugins/modules/oci_file_storage_snapshot.py +++ b/plugins/modules/oci_file_storage_snapshot.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a Snapshot resource in Oracle Cloud Infrastructure - For I(state=present), creates a new snapshot of the specified file system. You can access the snapshot at `.snapshot/`. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: file_system_id: description: @@ -73,10 +74,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -215,29 +212,23 @@ def get_resource(self): self.client.get_snapshot, snapshot_id=self.module.params.get("snapshot_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "file_system_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_snapshots, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_file_storage_snapshot_facts.py b/plugins/modules/oci_file_storage_snapshot_facts.py index b62efddcf1..220f963b14 100644 --- a/plugins/modules/oci_file_storage_snapshot_facts.py +++ b/plugins/modules/oci_file_storage_snapshot_facts.py @@ -63,10 +63,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_functions_application.py b/plugins/modules/oci_functions_application.py new file mode 100644 index 0000000000..2b1b629e7d --- /dev/null +++ b/plugins/modules/oci_functions_application.py @@ -0,0 +1,393 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_functions_application +short_description: Manage an Application resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete an Application resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new application. +version_added: "2.9" +author: Oracle (@oracle) +options: + compartment_id: + description: + - The OCID of the compartment to create the application within. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + display_name: + description: + - The display name of the application. The display name must be unique within the compartment containing the application. Avoid entering + confidential information. + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + aliases: ["name"] + config: + description: + - Application configuration. These values are passed on to the function as environment variables, functions may override application configuration. + Keys must be ASCII strings consisting solely of letters, digits, and the '_' (underscore) character, and must not begin with a digit. Values + should be limited to printable unicode characters. + - "Example: `{\\"MY_FUNCTION_CONFIG\\": \\"ConfVal\\"}`" + - The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each key + and value in UTF-8. + type: dict + subnet_ids: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the subnets in which to run functions in the + application. + - Required for create using I(state=present). + type: list + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + application_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this application. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the Application. + - Use I(state=present) to create or update an Application. + - Use I(state=absent) to delete an Application. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create application + oci_functions_application: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + display_name: display_name_example + +- name: Update application using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_functions_application: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + display_name: display_name_example + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + +- name: Update application + oci_functions_application: + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + application_id: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete application + oci_functions_application: + application_id: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete application using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_functions_application: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + display_name: display_name_example + state: absent + +""" + +RETURN = """ +application: + description: + - Details of the Application resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the application. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + compartment_id: + description: + - The OCID of the compartment that contains the application. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - The display name of the application. The display name is unique within the compartment containing the application. + returned: on success + type: string + sample: display_name_example + lifecycle_state: + description: + - The current state of the application. + returned: on success + type: string + sample: CREATING + config: + description: + - Application configuration for functions in this application (passed as environment variables). Can be overridden by function configuration. + Keys must be ASCII strings consisting solely of letters, digits, and the '_' (underscore) character, and must not begin with a digit. Values + should be limited to printable unicode characters. + - "Example: `{\\"MY_FUNCTION_CONFIG\\": \\"ConfVal\\"}`" + - The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each + key and value in UTF-8. + returned: on success + type: dict + sample: {} + subnet_ids: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the subnets in which to run functions in the + application. + returned: on success + type: list + sample: [] + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + time_created: + description: + - The time the application was created, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + time_updated: + description: + - "The time the application was updated, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "lifecycle_state": "CREATING", + "config": {}, + "subnet_ids": [], + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "time_created": "2018-09-12T22:47:12.613Z", + "time_updated": "2018-09-12T22:47:12.613Z" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.functions import FunctionsManagementClient + from oci.functions.models import CreateApplicationDetails + from oci.functions.models import UpdateApplicationDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ApplicationHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "application_id" + + def get_module_resource_id(self): + return self.module.params.get("application_id") + + def get_get_fn(self): + return self.client.get_application + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_application, + application_id=self.module.params.get("application_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_applications, **kwargs + ) + + def get_create_model_class(self): + return CreateApplicationDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_application, + call_fn_args=(), + call_fn_kwargs=dict(create_application_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateApplicationDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_application, + call_fn_args=(), + call_fn_kwargs=dict( + application_id=self.module.params.get("application_id"), + update_application_details=update_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_application, + call_fn_args=(), + call_fn_kwargs=dict( + application_id=self.module.params.get("application_id"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +ApplicationHelperCustom = get_custom_class("ApplicationHelperCustom") + + +class ResourceHelper(ApplicationHelperCustom, ApplicationHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + compartment_id=dict(type="str"), + display_name=dict(aliases=["name"], type="str"), + config=dict(type="dict"), + subnet_ids=dict(type="list"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + application_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="application", + service_client_class=FunctionsManagementClient, + namespace="functions", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_functions_application_facts.py b/plugins/modules/oci_functions_application_facts.py new file mode 100644 index 0000000000..1cc26f1eaf --- /dev/null +++ b/plugins/modules/oci_functions_application_facts.py @@ -0,0 +1,305 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_functions_application_facts +short_description: Fetches details about one or multiple Application resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Application resources in Oracle Cloud Infrastructure + - Lists applications for a compartment. + - If I(application_id) is specified, the details of a single Application will be returned. +version_added: "2.5" +options: + application_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this application. + - Required to get a specific application. + type: str + aliases: ["id"] + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this resource belongs. + - Required to list multiple applications. + type: str + lifecycle_state: + description: + - "A filter to return only applications that match the lifecycle state in this parameter. + Example: `Creating`" + type: str + choices: + - "CREATING" + - "ACTIVE" + - "INACTIVE" + - "UPDATING" + - "DELETING" + - "DELETED" + - "FAILED" + display_name: + description: + - A filter to return only applications with display names that match the display name string. Matching is exact. + type: str + aliases: ["name"] + id: + description: + - A filter to return only applications with the specfied OCID. + type: str + sort_order: + description: + - Specifies sort order. + - "* **ASC:** Ascending sort order. + * **DESC:** Descending sort order." + type: str + choices: + - "ASC" + - "DESC" + sort_by: + description: + - Specifies the attribute with which to sort the rules. + - "Default: `displayName`" + - "* **timeCreated:** Sorts by timeCreated. + * **displayName:** Sorts by displayName. + * **id:** Sorts by id." + type: str + choices: + - "timeCreated" + - "id" + - "displayName" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List applications + oci_functions_application_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific application + oci_functions_application_facts: + application_id: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +applications: + description: + - List of Application resources + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the application. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + compartment_id: + description: + - The OCID of the compartment that contains the application. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - The display name of the application. The display name is unique within the compartment containing the application. + returned: on success + type: string + sample: display_name_example + lifecycle_state: + description: + - The current state of the application. + returned: on success + type: string + sample: CREATING + config: + description: + - Application configuration for functions in this application (passed as environment variables). Can be overridden by function configuration. + Keys must be ASCII strings consisting solely of letters, digits, and the '_' (underscore) character, and must not begin with a digit. Values + should be limited to printable unicode characters. + - "Example: `{\\"MY_FUNCTION_CONFIG\\": \\"ConfVal\\"}`" + - The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each + key and value in UTF-8. + returned: on success + type: dict + sample: {} + subnet_ids: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the subnets in which to run functions in the + application. + returned: on success + type: list + sample: [] + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + time_created: + description: + - The time the application was created, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + time_updated: + description: + - "The time the application was updated, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "lifecycle_state": "CREATING", + "config": {}, + "subnet_ids": [], + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "time_created": "2018-09-12T22:47:12.613Z", + "time_updated": "2018-09-12T22:47:12.613Z" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.functions import FunctionsManagementClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ApplicationFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "application_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_application, + application_id=self.module.params.get("application_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "lifecycle_state", + "display_name", + "id", + "sort_order", + "sort_by", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_applications, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +ApplicationFactsHelperCustom = get_custom_class("ApplicationFactsHelperCustom") + + +class ResourceFactsHelper(ApplicationFactsHelperCustom, ApplicationFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + application_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + lifecycle_state=dict( + type="str", + choices=[ + "CREATING", + "ACTIVE", + "INACTIVE", + "UPDATING", + "DELETING", + "DELETED", + "FAILED", + ], + ), + display_name=dict(aliases=["name"], type="str"), + id=dict(type="str"), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + sort_by=dict(type="str", choices=["timeCreated", "id", "displayName"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="application", + service_client_class=FunctionsManagementClient, + namespace="functions", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(applications=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_functions_function.py b/plugins/modules/oci_functions_function.py new file mode 100644 index 0000000000..4854c3f1a6 --- /dev/null +++ b/plugins/modules/oci_functions_function.py @@ -0,0 +1,453 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_functions_function +short_description: Manage a Function resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a Function resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new function. + - "This resource has the following action operations in the M(oci_function_actions) module: invoke." +version_added: "2.9" +author: Oracle (@oracle) +options: + display_name: + description: + - The display name of the function. The display name must be unique within the application containing the function. Avoid entering confidential + information. + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + aliases: ["name"] + application_id: + description: + - The OCID of the application this function belongs to. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + image: + description: + - "The qualified name of the Docker image to use in the function, including the image tag. + The image should be in the OCI Registry that is in the same region as the function itself. + Example: `phx.ocir.io/ten/functions/function:0.0.1`" + - Required for create using I(state=present). + type: str + image_digest: + description: + - "The image digest for the version of the image that will be pulled when invoking this function. + If no value is specified, the digest currently associated with the image in the OCI Registry will be used. + Example: `sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7`" + type: str + memory_in_mbs: + description: + - Maximum usable memory for the function (MiB). + - Required for create using I(state=present). + type: int + config: + description: + - Function configuration. These values are passed on to the function as environment variables, this overrides application configuration values. + Keys must be ASCII strings consisting solely of letters, digits, and the '_' (underscore) character, and must not begin with a digit. Values + should be limited to printable unicode characters. + - "Example: `{\\"MY_FUNCTION_CONFIG\\": \\"ConfVal\\"}`" + - The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each key + and value in UTF-8. + type: dict + timeout_in_seconds: + description: + - Timeout for executions of the function. Value in seconds. + type: int + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + function_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this function. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the Function. + - Use I(state=present) to create or update a Function. + - Use I(state=absent) to delete a Function. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create function + oci_functions_function: + display_name: display_name_example + application_id: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + image: phx.ocir.io/ten/functions/function:0.0.1 + memory_in_mbs: 56 + +- name: Update function using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_functions_function: + display_name: display_name_example + application_id: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + image: phx.ocir.io/ten/functions/function:0.0.1 + image_digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7 + memory_in_mbs: 56 + timeout_in_seconds: 56 + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + +- name: Update function + oci_functions_function: + image: phx.ocir.io/ten/functions/function:0.0.1 + image_digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7 + function_id: ocid1.function.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete function + oci_functions_function: + function_id: ocid1.function.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete function using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_functions_function: + display_name: display_name_example + application_id: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +function: + description: + - Details of the Function resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the function. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - The display name of the function. The display name is unique within the application containing the function. + returned: on success + type: string + sample: display_name_example + lifecycle_state: + description: + - The current state of the function. + returned: on success + type: string + sample: CREATING + application_id: + description: + - The OCID of the application the function belongs to. + returned: on success + type: string + sample: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + compartment_id: + description: + - The OCID of the compartment that contains the function. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + image: + description: + - "The qualified name of the Docker image to use in the function, including the image tag. + The image should be in the OCI Registry that is in the same region as the function itself. + Example: `phx.ocir.io/ten/functions/function:0.0.1`" + returned: on success + type: string + sample: phx.ocir.io/ten/functions/function:0.0.1 + image_digest: + description: + - "The image digest for the version of the image that will be pulled when invoking this function. + If no value is specified, the digest currently associated with the image in the OCI Registry will be used. + Example: `sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7`" + returned: on success + type: string + sample: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7 + memory_in_mbs: + description: + - Maximum usable memory for the function (MiB). + returned: on success + type: int + sample: 56 + config: + description: + - Function configuration. Overrides application configuration. + Keys must be ASCII strings consisting solely of letters, digits, and the '_' (underscore) character, and must not begin with a digit. Values + should be limited to printable unicode characters. + - "Example: `{\\"MY_FUNCTION_CONFIG\\": \\"ConfVal\\"}`" + - The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each + key and value in UTF-8. + returned: on success + type: dict + sample: {} + timeout_in_seconds: + description: + - Timeout for executions of the function. Value in seconds. + returned: on success + type: int + sample: 56 + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + invoke_endpoint: + description: + - The base https invoke URL to set on a client in order to invoke a function. This URL will never change over the lifetime of the function and + can be cached. + returned: on success + type: string + sample: invoke_endpoint_example + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + time_created: + description: + - The time the function was created, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + time_updated: + description: + - The time the function was updated, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "lifecycle_state": "CREATING", + "application_id": "ocid1.application.oc1..xxxxxxEXAMPLExxxxxx", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "image": "phx.ocir.io/ten/functions/function:0.0.1", + "image_digest": "sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7", + "memory_in_mbs": 56, + "config": {}, + "timeout_in_seconds": 56, + "freeform_tags": {'Department': 'Finance'}, + "invoke_endpoint": "invoke_endpoint_example", + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "time_created": "2018-09-12T22:47:12.613Z", + "time_updated": "2018-09-12T22:47:12.613Z" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.functions import FunctionsManagementClient + from oci.functions.models import CreateFunctionDetails + from oci.functions.models import UpdateFunctionDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class FunctionHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "function_id" + + def get_module_resource_id(self): + return self.module.params.get("function_id") + + def get_get_fn(self): + return self.client.get_function + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_function, function_id=self.module.params.get("function_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "application_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_functions, **kwargs) + + def get_create_model_class(self): + return CreateFunctionDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_function, + call_fn_args=(), + call_fn_kwargs=dict(create_function_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateFunctionDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_function, + call_fn_args=(), + call_fn_kwargs=dict( + function_id=self.module.params.get("function_id"), + update_function_details=update_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_function, + call_fn_args=(), + call_fn_kwargs=dict(function_id=self.module.params.get("function_id"),), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +FunctionHelperCustom = get_custom_class("FunctionHelperCustom") + + +class ResourceHelper(FunctionHelperCustom, FunctionHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + display_name=dict(aliases=["name"], type="str"), + application_id=dict(type="str"), + image=dict(type="str"), + image_digest=dict(type="str"), + memory_in_mbs=dict(type="int"), + config=dict(type="dict"), + timeout_in_seconds=dict(type="int"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + function_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="function", + service_client_class=FunctionsManagementClient, + namespace="functions", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_functions_function_actions.py b/plugins/modules/oci_functions_function_actions.py new file mode 100644 index 0000000000..18d305188c --- /dev/null +++ b/plugins/modules/oci_functions_function_actions.py @@ -0,0 +1,316 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_functions_function_actions +short_description: Perform actions on a Function resource in Oracle Cloud Infrastructure +description: + - Perform actions on a Function resource in Oracle Cloud Infrastructure + - For I(action=invoke), invokes a function +version_added: "2.5" +options: + function_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this function. + type: str + aliases: ["id"] + required: true + invoke_function_body: + description: + - "The body of the function invocation. + Note: The maximum size of the request is limited. This limit is currently 6MB and the endpoint will not accept requests that are bigger than this + limit." + type: str + fn_intent: + description: + - An optional intent header that indicates to the FDK the way the event should be interpreted. E.g. 'httprequest', 'cloudevent'. + type: str + choices: + - "httprequest" + - "cloudevent" + fn_invoke_type: + description: + - Indicates whether the functions platform should execute the request directly and return the result ('sync') or + whether the platform should enqueue the request for later processing and acknowledge that it has been processed ('detached'). + type: str + choices: + - "detached" + - "sync" + dest: + description: + - The destination file path to write the output of I(action=invoke). The file will be created if it does not exist. If the file already exists, the + content will be overwritten. + type: str + action: + description: + - The action to perform on the Function. + type: str + required: true + choices: + - "invoke" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Perform action invoke on function + oci_functions_function_actions: + function_id: ocid1.function.oc1..xxxxxxEXAMPLExxxxxx + action: invoke + +""" + +RETURN = """ +function: + description: + - Details of the Function resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the function. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - The display name of the function. The display name is unique within the application containing the function. + returned: on success + type: string + sample: display_name_example + lifecycle_state: + description: + - The current state of the function. + returned: on success + type: string + sample: CREATING + application_id: + description: + - The OCID of the application the function belongs to. + returned: on success + type: string + sample: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + compartment_id: + description: + - The OCID of the compartment that contains the function. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + image: + description: + - "The qualified name of the Docker image to use in the function, including the image tag. + The image should be in the OCI Registry that is in the same region as the function itself. + Example: `phx.ocir.io/ten/functions/function:0.0.1`" + returned: on success + type: string + sample: phx.ocir.io/ten/functions/function:0.0.1 + image_digest: + description: + - "The image digest for the version of the image that will be pulled when invoking this function. + If no value is specified, the digest currently associated with the image in the OCI Registry will be used. + Example: `sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7`" + returned: on success + type: string + sample: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7 + memory_in_mbs: + description: + - Maximum usable memory for the function (MiB). + returned: on success + type: int + sample: 56 + config: + description: + - Function configuration. Overrides application configuration. + Keys must be ASCII strings consisting solely of letters, digits, and the '_' (underscore) character, and must not begin with a digit. Values + should be limited to printable unicode characters. + - "Example: `{\\"MY_FUNCTION_CONFIG\\": \\"ConfVal\\"}`" + - The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each + key and value in UTF-8. + returned: on success + type: dict + sample: {} + timeout_in_seconds: + description: + - Timeout for executions of the function. Value in seconds. + returned: on success + type: int + sample: 56 + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + invoke_endpoint: + description: + - The base https invoke URL to set on a client in order to invoke a function. This URL will never change over the lifetime of the function and + can be cached. + returned: on success + type: string + sample: invoke_endpoint_example + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + time_created: + description: + - The time the function was created, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + time_updated: + description: + - The time the function was updated, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "lifecycle_state": "CREATING", + "application_id": "ocid1.application.oc1..xxxxxxEXAMPLExxxxxx", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "image": "phx.ocir.io/ten/functions/function:0.0.1", + "image_digest": "sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7", + "memory_in_mbs": 56, + "config": {}, + "timeout_in_seconds": 56, + "freeform_tags": {'Department': 'Finance'}, + "invoke_endpoint": "invoke_endpoint_example", + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "time_created": "2018-09-12T22:47:12.613Z", + "time_updated": "2018-09-12T22:47:12.613Z" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIActionsHelperBase, + get_custom_class, +) + +try: + from oci.functions import FunctionsManagementClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class FunctionActionsHelperGen(OCIActionsHelperBase): + """ + Supported actions: + invoke + """ + + @staticmethod + def get_module_resource_id_param(): + return "function_id" + + def get_module_resource_id(self): + return self.module.params.get("function_id") + + def get_get_fn(self): + return self.client.get_function + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_function, function_id=self.module.params.get("function_id"), + ) + + def invoke(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.invoke_function, + call_fn_args=(), + call_fn_kwargs=dict( + function_id=self.module.params.get("function_id"), + invoke_function_body=self.module.params.get("invoke_function_body"), + fn_intent=self.module.params.get("fn_intent"), + fn_invoke_type=self.module.params.get("fn_invoke_type"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_action_desired_states( + self.module.params.get("action") + ), + ) + + +FunctionActionsHelperCustom = get_custom_class("FunctionActionsHelperCustom") + + +class ResourceHelper(FunctionActionsHelperCustom, FunctionActionsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + function_id=dict(aliases=["id"], type="str", required=True), + invoke_function_body=dict(type="str"), + fn_intent=dict(type="str", choices=["httprequest", "cloudevent"]), + fn_invoke_type=dict(type="str", choices=["detached", "sync"]), + dest=dict(type="str"), + action=dict(type="str", required=True, choices=["invoke"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="function", + service_client_class=FunctionsManagementClient, + namespace="functions", + ) + + result = resource_helper.perform_action(module.params.get("action")) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_functions_function_facts.py b/plugins/modules/oci_functions_function_facts.py new file mode 100644 index 0000000000..f93d1931cc --- /dev/null +++ b/plugins/modules/oci_functions_function_facts.py @@ -0,0 +1,343 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_functions_function_facts +short_description: Fetches details about one or multiple Function resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Function resources in Oracle Cloud Infrastructure + - Lists functions for an application. + - If I(function_id) is specified, the details of a single Function will be returned. +version_added: "2.5" +options: + function_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this function. + - Required to get a specific function. + type: str + aliases: ["id"] + application_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the application to which this function belongs. + - Required to list multiple functions. + type: str + lifecycle_state: + description: + - "A filter to return only functions that match the lifecycle state in this parameter. + Example: `Creating`" + type: str + choices: + - "CREATING" + - "ACTIVE" + - "INACTIVE" + - "UPDATING" + - "DELETING" + - "DELETED" + - "FAILED" + display_name: + description: + - A filter to return only functions with display names that match the display name string. Matching is exact. + type: str + aliases: ["name"] + id: + description: + - A filter to return only functions with the specified OCID. + type: str + sort_order: + description: + - Specifies sort order. + - "* **ASC:** Ascending sort order. + * **DESC:** Descending sort order." + type: str + choices: + - "ASC" + - "DESC" + sort_by: + description: + - Specifies the attribute with which to sort the rules. + - "Default: `displayName`" + - "* **timeCreated:** Sorts by timeCreated. + * **displayName:** Sorts by displayName. + * **id:** Sorts by id." + type: str + choices: + - "timeCreated" + - "id" + - "displayName" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List functions + oci_functions_function_facts: + application_id: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific function + oci_functions_function_facts: + function_id: ocid1.function.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +functions: + description: + - List of Function resources + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the function. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - The display name of the function. The display name is unique within the application containing the function. + returned: on success + type: string + sample: display_name_example + lifecycle_state: + description: + - The current state of the function. + returned: on success + type: string + sample: CREATING + application_id: + description: + - The OCID of the application the function belongs to. + returned: on success + type: string + sample: ocid1.application.oc1..xxxxxxEXAMPLExxxxxx + compartment_id: + description: + - The OCID of the compartment that contains the function. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + image: + description: + - "The qualified name of the Docker image to use in the function, including the image tag. + The image should be in the OCI Registry that is in the same region as the function itself. + Example: `phx.ocir.io/ten/functions/function:0.0.1`" + returned: on success + type: string + sample: phx.ocir.io/ten/functions/function:0.0.1 + image_digest: + description: + - "The image digest for the version of the image that will be pulled when invoking this function. + If no value is specified, the digest currently associated with the image in the OCI Registry will be used. + Example: `sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7`" + returned: on success + type: string + sample: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7 + memory_in_mbs: + description: + - Maximum usable memory for the function (MiB). + returned: on success + type: int + sample: 56 + config: + description: + - Function configuration. Overrides application configuration. + Keys must be ASCII strings consisting solely of letters, digits, and the '_' (underscore) character, and must not begin with a digit. Values + should be limited to printable unicode characters. + - "Example: `{\\"MY_FUNCTION_CONFIG\\": \\"ConfVal\\"}`" + - The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each + key and value in UTF-8. + returned: on success + type: dict + sample: {} + timeout_in_seconds: + description: + - Timeout for executions of the function. Value in seconds. + returned: on success + type: int + sample: 56 + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + invoke_endpoint: + description: + - The base https invoke URL to set on a client in order to invoke a function. This URL will never change over the lifetime of the function and + can be cached. + returned: on success + type: string + sample: invoke_endpoint_example + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + time_created: + description: + - The time the function was created, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + time_updated: + description: + - The time the function was updated, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2018-09-12T22:47:12.613Z`" + returned: on success + type: string + sample: 2018-09-12T22:47:12.613Z + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "lifecycle_state": "CREATING", + "application_id": "ocid1.application.oc1..xxxxxxEXAMPLExxxxxx", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "image": "phx.ocir.io/ten/functions/function:0.0.1", + "image_digest": "sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7", + "memory_in_mbs": 56, + "config": {}, + "timeout_in_seconds": 56, + "freeform_tags": {'Department': 'Finance'}, + "invoke_endpoint": "invoke_endpoint_example", + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "time_created": "2018-09-12T22:47:12.613Z", + "time_updated": "2018-09-12T22:47:12.613Z" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.functions import FunctionsManagementClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class FunctionFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "function_id", + ] + + def get_required_params_for_list(self): + return [ + "application_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_function, function_id=self.module.params.get("function_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "lifecycle_state", + "display_name", + "id", + "sort_order", + "sort_by", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_functions, + application_id=self.module.params.get("application_id"), + **optional_kwargs + ) + + +FunctionFactsHelperCustom = get_custom_class("FunctionFactsHelperCustom") + + +class ResourceFactsHelper(FunctionFactsHelperCustom, FunctionFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + function_id=dict(aliases=["id"], type="str"), + application_id=dict(type="str"), + lifecycle_state=dict( + type="str", + choices=[ + "CREATING", + "ACTIVE", + "INACTIVE", + "UPDATING", + "DELETING", + "DELETED", + "FAILED", + ], + ), + display_name=dict(aliases=["name"], type="str"), + id=dict(type="str"), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + sort_by=dict(type="str", choices=["timeCreated", "id", "displayName"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="function", + service_client_class=FunctionsManagementClient, + namespace="functions", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(functions=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_healthchecks_health_checks_vantage_point_facts.py b/plugins/modules/oci_healthchecks_health_checks_vantage_point_facts.py index 9d92aa94e3..978e1c391b 100644 --- a/plugins/modules/oci_healthchecks_health_checks_vantage_point_facts.py +++ b/plugins/modules/oci_healthchecks_health_checks_vantage_point_facts.py @@ -49,10 +49,7 @@ - Filters results that exactly match the `displayName` field. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_healthchecks_http_monitor.py b/plugins/modules/oci_healthchecks_http_monitor.py index efc1837f6b..7776f0fd90 100644 --- a/plugins/modules/oci_healthchecks_http_monitor.py +++ b/plugins/modules/oci_healthchecks_http_monitor.py @@ -26,7 +26,8 @@ - For I(state=present), creates an HTTP monitor. Vantage points will be automatically selected if not specified, and probes will be initiated from each vantage point to each of the targets at the frequency specified by `intervalInSeconds`. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -123,10 +124,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -347,31 +344,36 @@ def get_resource(self): monitor_id=self.module.params.get("monitor_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_http_monitors, **kwargs ) diff --git a/plugins/modules/oci_healthchecks_http_monitor_facts.py b/plugins/modules/oci_healthchecks_http_monitor_facts.py index efabc7df05..622b14c792 100644 --- a/plugins/modules/oci_healthchecks_http_monitor_facts.py +++ b/plugins/modules/oci_healthchecks_http_monitor_facts.py @@ -62,10 +62,7 @@ description: - Filters results that match the `homeRegion`. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_healthchecks_http_probe.py b/plugins/modules/oci_healthchecks_http_probe.py index 3fc08f0d3d..37a4adfedf 100644 --- a/plugins/modules/oci_healthchecks_http_probe.py +++ b/plugins/modules/oci_healthchecks_http_probe.py @@ -26,7 +26,8 @@ - For I(state=present), creates an on-demand HTTP probe. The location response header contains the URL for fetching the probe results. - "*Note:* On-demand probe configurations are not saved." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -84,10 +85,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -228,6 +225,13 @@ class HttpProbeHelperGen(OCIResourceHelperBase): """Supported operations: create""" + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + def get_create_model_class(self): return CreateOnDemandHttpProbeDetails diff --git a/plugins/modules/oci_healthchecks_http_probe_result_facts.py b/plugins/modules/oci_healthchecks_http_probe_result_facts.py index 28ee9a1f7e..755e86dbfe 100644 --- a/plugins/modules/oci_healthchecks_http_probe_result_facts.py +++ b/plugins/modules/oci_healthchecks_http_probe_result_facts.py @@ -52,10 +52,7 @@ description: - Filters results that match the `target`. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_healthchecks_ping_monitor.py b/plugins/modules/oci_healthchecks_ping_monitor.py index d2edf426e0..485f4ddd19 100644 --- a/plugins/modules/oci_healthchecks_ping_monitor.py +++ b/plugins/modules/oci_healthchecks_ping_monitor.py @@ -26,7 +26,8 @@ - For I(state=present), creates a ping monitor. Vantage points will be automatically selected if not specified, and probes will be initiated from each vantage point to each of the targets at the frequency specified by `intervalInSeconds`. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -107,10 +108,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -307,31 +304,36 @@ def get_resource(self): monitor_id=self.module.params.get("monitor_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_ping_monitors, **kwargs ) diff --git a/plugins/modules/oci_healthchecks_ping_monitor_facts.py b/plugins/modules/oci_healthchecks_ping_monitor_facts.py index a893525a71..62a5094296 100644 --- a/plugins/modules/oci_healthchecks_ping_monitor_facts.py +++ b/plugins/modules/oci_healthchecks_ping_monitor_facts.py @@ -64,10 +64,7 @@ description: - Filters results that match the `homeRegion`. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_healthchecks_ping_probe.py b/plugins/modules/oci_healthchecks_ping_probe.py index 4f958c4acb..a6e16a9d85 100644 --- a/plugins/modules/oci_healthchecks_ping_probe.py +++ b/plugins/modules/oci_healthchecks_ping_probe.py @@ -26,7 +26,8 @@ - For I(state=present), creates an on-demand ping probe. The location response header contains the URL for fetching probe results. - "*Note:* The on-demand probe configuration is not saved." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -68,10 +69,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -190,6 +187,13 @@ class PingProbeHelperGen(OCIResourceHelperBase): """Supported operations: create""" + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + def get_create_model_class(self): return CreateOnDemandPingProbeDetails diff --git a/plugins/modules/oci_healthchecks_ping_probe_result_facts.py b/plugins/modules/oci_healthchecks_ping_probe_result_facts.py index e1ae8ce0ab..e930c05b5f 100644 --- a/plugins/modules/oci_healthchecks_ping_probe_result_facts.py +++ b/plugins/modules/oci_healthchecks_ping_probe_result_facts.py @@ -55,10 +55,7 @@ description: - Filters results that match the `target`. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_api_key.py b/plugins/modules/oci_identity_api_key.py index 11435392fe..ca3f89600f 100644 --- a/plugins/modules/oci_identity_api_key.py +++ b/plugins/modules/oci_identity_api_key.py @@ -35,7 +35,8 @@ you have. Also confirm you're working in the correct compartment." - After you send your request, the new object's `lifecycleState` will temporarily be CREATING. Before using the object, first make sure its `lifecycleState` has changed to ACTIVE. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: user_id: description: @@ -61,10 +62,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -181,29 +178,23 @@ def get_resource(self): oci_common_utils.raise_does_not_exist_service_error() - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "user_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_api_keys, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_identity_api_key_facts.py b/plugins/modules/oci_identity_api_key_facts.py index 2001044d65..249e15863f 100644 --- a/plugins/modules/oci_identity_api_key_facts.py +++ b/plugins/modules/oci_identity_api_key_facts.py @@ -33,10 +33,7 @@ - The OCID of the user. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_auth_token.py b/plugins/modules/oci_identity_auth_token.py index 33c6525819..567f90ce74 100644 --- a/plugins/modules/oci_identity_auth_token.py +++ b/plugins/modules/oci_identity_auth_token.py @@ -31,7 +31,8 @@ - "Every user has permission to create an auth token for *their own user ID*. An administrator in your organization does not need to write a policy to give users this ability. To compare, administrators who have permission to the tenancy can use this operation to create an auth token for any user, including themselves." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: description: description: @@ -59,10 +60,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -195,29 +192,23 @@ def get_resource(self): oci_common_utils.raise_does_not_exist_service_error() - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "user_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_auth_tokens, **kwargs ) diff --git a/plugins/modules/oci_identity_auth_token_facts.py b/plugins/modules/oci_identity_auth_token_facts.py index 7c3e5a86ca..c89cf3da43 100644 --- a/plugins/modules/oci_identity_auth_token_facts.py +++ b/plugins/modules/oci_identity_auth_token_facts.py @@ -32,10 +32,7 @@ - The OCID of the user. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_authentication_policy.py b/plugins/modules/oci_identity_authentication_policy.py index e636fcf80c..03fb2ece12 100644 --- a/plugins/modules/oci_identity_authentication_policy.py +++ b/plugins/modules/oci_identity_authentication_policy.py @@ -23,7 +23,8 @@ short_description: Manage an AuthenticationPolicy resource in Oracle Cloud Infrastructure description: - This module allows the user to update an AuthenticationPolicy resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -68,10 +69,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_authentication_policy_facts.py b/plugins/modules/oci_identity_authentication_policy_facts.py index 28a7a82cbb..693816abbe 100644 --- a/plugins/modules/oci_identity_authentication_policy_facts.py +++ b/plugins/modules/oci_identity_authentication_policy_facts.py @@ -33,10 +33,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_availability_domain_facts.py b/plugins/modules/oci_identity_availability_domain_facts.py index 6539da3c05..df72b79a21 100644 --- a/plugins/modules/oci_identity_availability_domain_facts.py +++ b/plugins/modules/oci_identity_availability_domain_facts.py @@ -35,10 +35,7 @@ - The OCID of the compartment (remember that the tenancy is simply the root compartment). type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_compartment.py b/plugins/modules/oci_identity_compartment.py index 99c76a547c..3a783e70c8 100644 --- a/plugins/modules/oci_identity_compartment.py +++ b/plugins/modules/oci_identity_compartment.py @@ -37,7 +37,8 @@ L(UpdateCompartment,https://docs.cloud.oracle.com/#/en/identity/20160918/Compartment/UpdateCompartment)." - After you send your request, the new object's `lifecycleState` will temporarily be CREATING. Before using the object, first make sure its `lifecycleState` has changed to ACTIVE. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: parent_compartment_id: description: @@ -86,10 +87,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -255,29 +252,23 @@ def get_resource(self): compartment_id=self.module.params.get("compartment_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_compartments, **kwargs ) diff --git a/plugins/modules/oci_identity_compartment_facts.py b/plugins/modules/oci_identity_compartment_facts.py index e3ae1a4109..c6f4d37b85 100644 --- a/plugins/modules/oci_identity_compartment_facts.py +++ b/plugins/modules/oci_identity_compartment_facts.py @@ -71,10 +71,7 @@ and all compartments and subcompartments in the tenancy are returned depending on the the setting of `accessLevel`. type: bool -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_cost_tracking_tag_facts.py b/plugins/modules/oci_identity_cost_tracking_tag_facts.py index fc74825ec8..59d3f07439 100644 --- a/plugins/modules/oci_identity_cost_tracking_tag_facts.py +++ b/plugins/modules/oci_identity_cost_tracking_tag_facts.py @@ -32,10 +32,7 @@ - The OCID of the compartment (remember that the tenancy is simply the root compartment). type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_customer_secret_key.py b/plugins/modules/oci_identity_customer_secret_key.py index adedde125f..ee9018a8a3 100644 --- a/plugins/modules/oci_identity_customer_secret_key.py +++ b/plugins/modules/oci_identity_customer_secret_key.py @@ -32,7 +32,8 @@ - "Every user has permission to create a secret key for *their own user ID*. An administrator in your organization does not need to write a policy to give users this ability. To compare, administrators who have permission to the tenancy can use this operation to create a secret key for any user, including themselves." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: display_name: description: @@ -62,10 +63,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -201,29 +198,23 @@ def get_resource(self): oci_common_utils.raise_does_not_exist_service_error() - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "user_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_customer_secret_keys, **kwargs ) diff --git a/plugins/modules/oci_identity_customer_secret_key_facts.py b/plugins/modules/oci_identity_customer_secret_key_facts.py index 754824651b..a8fb223483 100644 --- a/plugins/modules/oci_identity_customer_secret_key_facts.py +++ b/plugins/modules/oci_identity_customer_secret_key_facts.py @@ -32,10 +32,7 @@ - The OCID of the user. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_identity_dynamic_group.py b/plugins/modules/oci_identity_dynamic_group.py index d43367ce83..1ea1b05b9e 100644 --- a/plugins/modules/oci_identity_dynamic_group.py +++ b/plugins/modules/oci_identity_dynamic_group.py @@ -38,7 +38,8 @@ L(UpdateDynamicGroup,https://docs.cloud.oracle.com/#/en/identity/20160918/DynamicGroup/UpdateDynamicGroup)." - After you send your request, the new object's `lifecycleState` will temporarily be CREATING. Before using the object, first make sure its `lifecycleState` has changed to ACTIVE. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -93,10 +94,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -263,29 +260,23 @@ def get_resource(self): dynamic_group_id=self.module.params.get("dynamic_group_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_dynamic_groups, **kwargs ) diff --git a/plugins/modules/oci_identity_dynamic_group_facts.py b/plugins/modules/oci_identity_dynamic_group_facts.py index 34647626bd..741674447c 100644 --- a/plugins/modules/oci_identity_dynamic_group_facts.py +++ b/plugins/modules/oci_identity_dynamic_group_facts.py @@ -40,10 +40,7 @@ - The OCID of the compartment (remember that the tenancy is simply the root compartment). - Required to list multiple dynamic_groups. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_fault_domain_facts.py b/plugins/modules/oci_identity_fault_domain_facts.py index e2a85f87b8..b847cfd253 100644 --- a/plugins/modules/oci_identity_fault_domain_facts.py +++ b/plugins/modules/oci_identity_fault_domain_facts.py @@ -38,10 +38,7 @@ - The name of the availibilityDomain. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_group.py b/plugins/modules/oci_identity_group.py index 647a7261b0..b3137181b8 100644 --- a/plugins/modules/oci_identity_group.py +++ b/plugins/modules/oci_identity_group.py @@ -39,7 +39,8 @@ - After creating the group, you need to put users in it and write policies for it. See L(AddUserToGroup,https://docs.cloud.oracle.com/#/en/identity/20160918/UserGroupMembership/AddUserToGroup) and L(CreatePolicy,https://docs.cloud.oracle.com/#/en/identity/20160918/Policy/CreatePolicy). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -88,10 +89,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -247,29 +244,23 @@ def get_resource(self): self.client.get_group, group_id=self.module.params.get("group_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_groups, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_identity_group_facts.py b/plugins/modules/oci_identity_group_facts.py index 2274ad4f2d..99c5431475 100644 --- a/plugins/modules/oci_identity_group_facts.py +++ b/plugins/modules/oci_identity_group_facts.py @@ -40,10 +40,7 @@ - The OCID of the compartment (remember that the tenancy is simply the root compartment). - Required to list multiple groups. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_idp_group_mapping.py b/plugins/modules/oci_identity_idp_group_mapping.py index c418762569..288dcc2501 100644 --- a/plugins/modules/oci_identity_idp_group_mapping.py +++ b/plugins/modules/oci_identity_idp_group_mapping.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete an IdpGroupMapping resource in Oracle Cloud Infrastructure - For I(state=present), creates a single mapping between an IdP group and an IAM Service L(group,https://docs.cloud.oracle.com/#/en/identity/20160918/Group/). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: idp_group_name: description: @@ -59,10 +60,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -196,29 +193,23 @@ def get_resource(self): mapping_id=self.module.params.get("mapping_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "identity_provider_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_idp_group_mappings, **kwargs ) diff --git a/plugins/modules/oci_identity_idp_group_mapping_facts.py b/plugins/modules/oci_identity_idp_group_mapping_facts.py index 84f0f401f9..1069ed73e6 100644 --- a/plugins/modules/oci_identity_idp_group_mapping_facts.py +++ b/plugins/modules/oci_identity_idp_group_mapping_facts.py @@ -38,10 +38,7 @@ - Required to get a specific idp_group_mapping. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_mfa_totp_device.py b/plugins/modules/oci_identity_mfa_totp_device.py index 987f9ba9b1..f65b039002 100644 --- a/plugins/modules/oci_identity_mfa_totp_device.py +++ b/plugins/modules/oci_identity_mfa_totp_device.py @@ -25,7 +25,8 @@ - This module allows the user to create and delete a MfaTotpDevice resource in Oracle Cloud Infrastructure - For I(state=present), creates a new MFA TOTP device for the user. A user can have one MFA TOTP device. - "This resource has the following action operations in the M(oci_mfa_totp_device_actions) module: activate, generate_totp_seed." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: user_id: description: @@ -47,10 +48,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -172,29 +169,23 @@ def get_resource(self): mfa_totp_device_id=self.module.params.get("mfa_totp_device_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "user_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_mfa_totp_devices, **kwargs ) diff --git a/plugins/modules/oci_identity_mfa_totp_device_actions.py b/plugins/modules/oci_identity_mfa_totp_device_actions.py index d9276c81ae..5c605a8343 100644 --- a/plugins/modules/oci_identity_mfa_totp_device_actions.py +++ b/plugins/modules/oci_identity_mfa_totp_device_actions.py @@ -48,11 +48,10 @@ - The action to perform on the MfaTotpDevice. type: str required: true - choices: ["activate", "generate_totp_seed"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "activate" + - "generate_totp_seed" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_identity_mfa_totp_device_facts.py b/plugins/modules/oci_identity_mfa_totp_device_facts.py index bd618ae944..efb0140014 100644 --- a/plugins/modules/oci_identity_mfa_totp_device_facts.py +++ b/plugins/modules/oci_identity_mfa_totp_device_facts.py @@ -60,10 +60,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_policy.py b/plugins/modules/oci_identity_policy.py index cf00ab601d..d23aa70fec 100644 --- a/plugins/modules/oci_identity_policy.py +++ b/plugins/modules/oci_identity_policy.py @@ -35,7 +35,8 @@ - After you send your request, the new object's `lifecycleState` will temporarily be CREATING. Before using the object, first make sure its `lifecycleState` has changed to ACTIVE. - New policies take effect typically within 10 seconds. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -97,10 +98,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -278,29 +275,23 @@ def get_resource(self): self.client.get_policy, policy_id=self.module.params.get("policy_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_policies, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_identity_policy_facts.py b/plugins/modules/oci_identity_policy_facts.py index 4426dbd272..18df15e8fb 100644 --- a/plugins/modules/oci_identity_policy_facts.py +++ b/plugins/modules/oci_identity_policy_facts.py @@ -41,10 +41,7 @@ - The OCID of the compartment (remember that the tenancy is simply the root compartment). - Required to list multiple policies. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_provider.py b/plugins/modules/oci_identity_provider.py index dae4713d60..f09a5baa06 100644 --- a/plugins/modules/oci_identity_provider.py +++ b/plugins/modules/oci_identity_provider.py @@ -38,7 +38,8 @@ be CREATING. Before using the object, first make sure its `lifecycleState` has changed to ACTIVE. - "This resource has the following action operations in the M(oci_identity_provider_actions) module: reset_idp_scim_client." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -128,10 +129,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -363,30 +360,24 @@ def get_resource(self): identity_provider_id=self.module.params.get("identity_provider_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "protocol", "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_identity_providers, **kwargs ) diff --git a/plugins/modules/oci_identity_provider_actions.py b/plugins/modules/oci_identity_provider_actions.py index 6d7b4c82ac..cd28256b63 100644 --- a/plugins/modules/oci_identity_provider_actions.py +++ b/plugins/modules/oci_identity_provider_actions.py @@ -37,11 +37,9 @@ - The action to perform on the IdentityProvider. type: str required: true - choices: ["reset_idp_scim_client"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "reset_idp_scim_client" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_provider_facts.py b/plugins/modules/oci_identity_provider_facts.py index 01bfa371b3..2d0f6a3f9a 100644 --- a/plugins/modules/oci_identity_provider_facts.py +++ b/plugins/modules/oci_identity_provider_facts.py @@ -48,10 +48,7 @@ - The OCID of the compartment (remember that the tenancy is simply the root compartment). - Required to list multiple identity_providers. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_provider_group_facts.py b/plugins/modules/oci_identity_provider_group_facts.py index e1c5cf29bd..4ce8a135ee 100644 --- a/plugins/modules/oci_identity_provider_group_facts.py +++ b/plugins/modules/oci_identity_provider_group_facts.py @@ -31,10 +31,7 @@ - The OCID of the identity provider. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_identity_region_facts.py b/plugins/modules/oci_identity_region_facts.py index a230dde92d..3c38589e55 100644 --- a/plugins/modules/oci_identity_region_facts.py +++ b/plugins/modules/oci_identity_region_facts.py @@ -26,10 +26,7 @@ - Lists all the regions offered by Oracle Cloud Infrastructure. version_added: "2.5" options: {} -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_region_subscription_facts.py b/plugins/modules/oci_identity_region_subscription_facts.py index bbea9223e3..63e668e830 100644 --- a/plugins/modules/oci_identity_region_subscription_facts.py +++ b/plugins/modules/oci_identity_region_subscription_facts.py @@ -31,10 +31,7 @@ - The OCID of the tenancy. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_smtp_credential.py b/plugins/modules/oci_identity_smtp_credential.py index f777604f67..c80ad08089 100644 --- a/plugins/modules/oci_identity_smtp_credential.py +++ b/plugins/modules/oci_identity_smtp_credential.py @@ -27,7 +27,8 @@ You must specify a *description* for the SMTP credential (although it can be an empty string). It does not have to be unique, and you can change it anytime with L(UpdateSmtpCredential,https://docs.cloud.oracle.com/#/en/identity/20160918/SmtpCredentialSummary/UpdateSmtpCredential)." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: description: description: @@ -55,10 +56,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -190,29 +187,23 @@ def get_resource(self): oci_common_utils.raise_does_not_exist_service_error() - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "user_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_smtp_credentials, **kwargs ) diff --git a/plugins/modules/oci_identity_smtp_credential_facts.py b/plugins/modules/oci_identity_smtp_credential_facts.py index 12ac094cd7..22fbb63dd6 100644 --- a/plugins/modules/oci_identity_smtp_credential_facts.py +++ b/plugins/modules/oci_identity_smtp_credential_facts.py @@ -32,10 +32,7 @@ - The OCID of the user. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_tag.py b/plugins/modules/oci_identity_tag.py index 974862d219..7e79899d87 100644 --- a/plugins/modules/oci_identity_tag.py +++ b/plugins/modules/oci_identity_tag.py @@ -40,7 +40,8 @@ value or leave the tag value empty. * If a `validator` is set, the user applying the tag to a resource must select from a list of values that you supply with L(EnumTagDefinitionValidator,https://docs.cloud.oracle.com/#/en/identity/latest/datatypes/EnumTagDefinitionValidator)." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: tag_namespace_id: description: @@ -113,10 +114,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -313,29 +310,23 @@ def get_resource(self): tag_name=self.module.params.get("name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "tag_namespace_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_tags, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_identity_tag_default.py b/plugins/modules/oci_identity_tag_default.py index 20d1037a0c..42a8409048 100644 --- a/plugins/modules/oci_identity_tag_default.py +++ b/plugins/modules/oci_identity_tag_default.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a TagDefault resource in Oracle Cloud Infrastructure - For I(state=present), creates a new tag default in the specified compartment for the specified tag definition. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -57,10 +58,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -190,30 +187,30 @@ def get_resource(self): tag_default_id=self.module.params.get("tag_default_id"), ) - def list_resources(self): - required_list_method_params = [] - - optional_list_method_params = [ - "compartment_id", - "tag_definition_id", - ] + def get_required_kwargs_for_list(self): + return dict() - required_kwargs = dict( - (param, self.module.params[param]) for param in required_list_method_params - ) + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["compartment_id", "tag_definition_id"] - optional_kwargs = dict( + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_tag_defaults, **kwargs ) diff --git a/plugins/modules/oci_identity_tag_default_facts.py b/plugins/modules/oci_identity_tag_default_facts.py index f34b77b93a..5cddc6b470 100644 --- a/plugins/modules/oci_identity_tag_default_facts.py +++ b/plugins/modules/oci_identity_tag_default_facts.py @@ -51,10 +51,7 @@ type: str choices: - "ACTIVE" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_tag_facts.py b/plugins/modules/oci_identity_tag_facts.py index a891ba9ed4..76d42a96e4 100644 --- a/plugins/modules/oci_identity_tag_facts.py +++ b/plugins/modules/oci_identity_tag_facts.py @@ -46,10 +46,7 @@ - "INACTIVE" - "DELETING" - "DELETED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_identity_tag_namespace.py b/plugins/modules/oci_identity_tag_namespace.py index f554be21aa..83a57c131d 100644 --- a/plugins/modules/oci_identity_tag_namespace.py +++ b/plugins/modules/oci_identity_tag_namespace.py @@ -34,7 +34,8 @@ - "You must also specify a *description* for the namespace. It does not have to be unique, and you can change it with L(UpdateTagNamespace,https://docs.cloud.oracle.com/#/en/identity/latest/TagNamespace/UpdateTagNamespace)." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -87,10 +88,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -249,29 +246,23 @@ def get_resource(self): tag_namespace_id=self.module.params.get("tag_namespace_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_tag_namespaces, **kwargs ) diff --git a/plugins/modules/oci_identity_tag_namespace_facts.py b/plugins/modules/oci_identity_tag_namespace_facts.py index 1a1f2e064e..629804f89d 100644 --- a/plugins/modules/oci_identity_tag_namespace_facts.py +++ b/plugins/modules/oci_identity_tag_namespace_facts.py @@ -52,10 +52,7 @@ - "INACTIVE" - "DELETING" - "DELETED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_tenancy_facts.py b/plugins/modules/oci_identity_tenancy_facts.py index 8b695616ff..7724a8833f 100644 --- a/plugins/modules/oci_identity_tenancy_facts.py +++ b/plugins/modules/oci_identity_tenancy_facts.py @@ -32,10 +32,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_ui_password.py b/plugins/modules/oci_identity_ui_password.py index 4137bf138e..f116df0f8e 100644 --- a/plugins/modules/oci_identity_ui_password.py +++ b/plugins/modules/oci_identity_ui_password.py @@ -32,7 +32,8 @@ user. - "**Note:** The user's Console login is the unique name you specified when you created the user (see L(CreateUser,https://docs.cloud.oracle.com/#/en/identity/20160918/User/CreateUser))." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: user_id: description: @@ -47,10 +48,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -130,6 +127,13 @@ class UiPasswordHelperGen(OCIResourceHelperBase): """Supported operations: create""" + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + def create_resource(self): return oci_wait_utils.call_and_wait( call_fn=self.client.create_or_reset_ui_password, diff --git a/plugins/modules/oci_identity_user.py b/plugins/modules/oci_identity_user.py index e6b3cb0378..68a08e3ce6 100644 --- a/plugins/modules/oci_identity_user.py +++ b/plugins/modules/oci_identity_user.py @@ -52,7 +52,8 @@ L(Required Keys and OCIDs,https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm) and also L(UploadApiKey,https://docs.cloud.oracle.com/#/en/identity/20160918/ApiKey/UploadApiKey)). - "**Important:** Make sure to inform the new user which compartment(s) they have access to." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -105,10 +106,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -341,29 +338,23 @@ def get_resource(self): self.client.get_user, user_id=self.module.params.get("user_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_users, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_identity_user_facts.py b/plugins/modules/oci_identity_user_facts.py index aaff004843..a6b9664c47 100644 --- a/plugins/modules/oci_identity_user_facts.py +++ b/plugins/modules/oci_identity_user_facts.py @@ -48,10 +48,7 @@ description: - The id of a user in the identity provider. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_identity_user_group_membership.py b/plugins/modules/oci_identity_user_group_membership.py index c2134b773c..24eb976511 100644 --- a/plugins/modules/oci_identity_user_group_membership.py +++ b/plugins/modules/oci_identity_user_group_membership.py @@ -26,7 +26,8 @@ - For I(state=present), adds the specified user to the specified group and returns a `UserGroupMembership` object with its own OCID. - After you send your request, the new object's `lifecycleState` will temporarily be CREATING. Before using the object, first make sure its `lifecycleState` has changed to ACTIVE. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: user_id: description: @@ -58,10 +59,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -178,32 +175,36 @@ def get_resource(self): user_group_membership_id=self.module.params.get("user_group_membership_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "user_id", - "group_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["user_id", "group_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_user_group_memberships, **kwargs ) diff --git a/plugins/modules/oci_identity_user_group_membership_facts.py b/plugins/modules/oci_identity_user_group_membership_facts.py index 7c6b9c24b6..a56eac929d 100644 --- a/plugins/modules/oci_identity_user_group_membership_facts.py +++ b/plugins/modules/oci_identity_user_group_membership_facts.py @@ -54,10 +54,7 @@ description: - The OCID of the group. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_key_management_decrypted_data.py b/plugins/modules/oci_key_management_decrypted_data.py index 8b36858c9d..726ad2c214 100644 --- a/plugins/modules/oci_key_management_decrypted_data.py +++ b/plugins/modules/oci_key_management_decrypted_data.py @@ -25,7 +25,8 @@ - This module allows the user to create a DecryptedData resource in Oracle Cloud Infrastructure - For I(state=present), decrypts data using the given L(DecryptDataDetails,https://docs.cloud.oracle.com/api/#/en/key/release/datatypes/DecryptDataDetails) resource. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: associated_data: description: @@ -60,10 +61,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -122,6 +119,13 @@ class DecryptedDataHelperGen(OCIResourceHelperBase): """Supported operations: create""" + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + def get_create_model_class(self): return DecryptDataDetails diff --git a/plugins/modules/oci_key_management_encrypted_data.py b/plugins/modules/oci_key_management_encrypted_data.py index 397f4a77de..c4c452a571 100644 --- a/plugins/modules/oci_key_management_encrypted_data.py +++ b/plugins/modules/oci_key_management_encrypted_data.py @@ -26,7 +26,8 @@ - For I(state=present), encrypts data using the given L(EncryptDataDetails,https://docs.cloud.oracle.com/api/#/en/key/release/datatypes/EncryptDataDetails) resource. Plaintext included in the example request is a base64-encoded value of a UTF-8 string. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: associated_data: description: @@ -62,10 +63,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -118,6 +115,13 @@ class EncryptedDataHelperGen(OCIResourceHelperBase): """Supported operations: create""" + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + def get_create_model_class(self): return EncryptDataDetails diff --git a/plugins/modules/oci_key_management_generated_key.py b/plugins/modules/oci_key_management_generated_key.py index 36801e054a..3f23c32411 100644 --- a/plugins/modules/oci_key_management_generated_key.py +++ b/plugins/modules/oci_key_management_generated_key.py @@ -24,7 +24,8 @@ description: - This module allows the user to create a GeneratedKey resource in Oracle Cloud Infrastructure - For I(state=present), generates a key that you can use to encrypt or decrypt data. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: associated_data: description: @@ -79,10 +80,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -156,6 +153,13 @@ class GeneratedKeyHelperGen(OCIResourceHelperBase): """Supported operations: create""" + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + def get_create_model_class(self): return GenerateKeyDetails diff --git a/plugins/modules/oci_key_management_key.py b/plugins/modules/oci_key_management_key.py index 5069ee213b..2b17ca28af 100644 --- a/plugins/modules/oci_key_management_key.py +++ b/plugins/modules/oci_key_management_key.py @@ -29,7 +29,8 @@ to reject an otherwise valid request when the total rate of management write operations exceeds 10 requests per second for a given tenancy. - "This resource has the following action operations in the M(oci_key_actions) module: cancel_key_deletion, disable, enable, schedule_key_deletion." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -95,10 +96,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -274,29 +271,23 @@ def get_resource(self): self.client.get_key, key_id=self.module.params.get("key_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_keys, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_key_management_key_actions.py b/plugins/modules/oci_key_management_key_actions.py index 20386153ff..1ecf8b8432 100644 --- a/plugins/modules/oci_key_management_key_actions.py +++ b/plugins/modules/oci_key_management_key_actions.py @@ -75,11 +75,12 @@ - The action to perform on the Key. type: str required: true - choices: ["cancel_key_deletion", "disable", "enable", "schedule_key_deletion"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "cancel_key_deletion" + - "disable" + - "enable" + - "schedule_key_deletion" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_key_management_key_facts.py b/plugins/modules/oci_key_management_key_facts.py index d8ea46af98..a0e43e53c5 100644 --- a/plugins/modules/oci_key_management_key_facts.py +++ b/plugins/modules/oci_key_management_key_facts.py @@ -63,10 +63,7 @@ - The endpoint of the service to call using this client. For example 'https://kms.{region}.{secondLevelDomain}'. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_key_management_key_version.py b/plugins/modules/oci_key_management_key_version.py index 823f4812e2..7c9852e684 100644 --- a/plugins/modules/oci_key_management_key_version.py +++ b/plugins/modules/oci_key_management_key_version.py @@ -31,7 +31,8 @@ otherwise valid request when the total rate of management write operations exceeds 10 requests per second for a given tenancy. - "This resource has the following action operations in the M(oci_key_version_actions) module: cancel_key_version_deletion, schedule_key_version_deletion." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: key_id: description: @@ -51,10 +52,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -170,29 +167,23 @@ def get_resource(self): key_version_id=self.module.params.get("key_version_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "key_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_key_versions, **kwargs ) diff --git a/plugins/modules/oci_key_management_key_version_actions.py b/plugins/modules/oci_key_management_key_version_actions.py index 902dd3ba9a..c64b45b4d5 100644 --- a/plugins/modules/oci_key_management_key_version_actions.py +++ b/plugins/modules/oci_key_management_key_version_actions.py @@ -66,11 +66,10 @@ - The action to perform on the KeyVersion. type: str required: true - choices: ["cancel_key_version_deletion", "schedule_key_version_deletion"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "cancel_key_version_deletion" + - "schedule_key_version_deletion" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_key_management_key_version_facts.py b/plugins/modules/oci_key_management_key_version_facts.py index 9e37f444ce..faf3c9b4b8 100644 --- a/plugins/modules/oci_key_management_key_version_facts.py +++ b/plugins/modules/oci_key_management_key_version_facts.py @@ -64,10 +64,7 @@ - The endpoint of the service to call using this client. For example 'https://kms.{region}.{secondLevelDomain}'. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_key_management_vault.py b/plugins/modules/oci_key_management_vault.py index ce5e914767..d18f95d130 100644 --- a/plugins/modules/oci_key_management_vault.py +++ b/plugins/modules/oci_key_management_vault.py @@ -32,7 +32,8 @@ throttle this call to reject an otherwise valid request when the total rate of provisioning write operations exceeds 10 requests per second for a given tenancy. - "This resource has the following action operations in the M(oci_vault_actions) module: cancel_vault_deletion, schedule_vault_deletion." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -82,10 +83,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -251,29 +248,23 @@ def get_resource(self): self.client.get_vault, vault_id=self.module.params.get("vault_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_vaults, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_key_management_vault_actions.py b/plugins/modules/oci_key_management_vault_actions.py index 49493f2bd3..f9db98fb9d 100644 --- a/plugins/modules/oci_key_management_vault_actions.py +++ b/plugins/modules/oci_key_management_vault_actions.py @@ -62,11 +62,10 @@ - The action to perform on the Vault. type: str required: true - choices: ["cancel_vault_deletion", "schedule_vault_deletion"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "cancel_vault_deletion" + - "schedule_vault_deletion" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_key_management_vault_facts.py b/plugins/modules/oci_key_management_vault_facts.py index 8676c097bf..8102e76c92 100644 --- a/plugins/modules/oci_key_management_vault_facts.py +++ b/plugins/modules/oci_key_management_vault_facts.py @@ -58,10 +58,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_loadbalancer_backend.py b/plugins/modules/oci_loadbalancer_backend.py index b534dd2c2c..4ef7d6ad89 100644 --- a/plugins/modules/oci_loadbalancer_backend.py +++ b/plugins/modules/oci_loadbalancer_backend.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a Backend resource in Oracle Cloud Infrastructure - For I(state=present), adds a backend server to a backend set. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: ip_address: description: @@ -92,10 +93,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -239,30 +236,24 @@ def get_resource(self): backend_name=self.module.params.get("backend_name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "load_balancer_id", "backend_set_name", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_backends, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_loadbalancer_backend_facts.py b/plugins/modules/oci_loadbalancer_backend_facts.py index 9e97e2d399..0539747573 100644 --- a/plugins/modules/oci_loadbalancer_backend_facts.py +++ b/plugins/modules/oci_loadbalancer_backend_facts.py @@ -46,10 +46,7 @@ - "Example: `10.0.0.3:8080`" - Required to get a specific backend. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_backend_health_facts.py b/plugins/modules/oci_loadbalancer_backend_health_facts.py index 9432fc4655..8bc29fef89 100644 --- a/plugins/modules/oci_loadbalancer_backend_health_facts.py +++ b/plugins/modules/oci_loadbalancer_backend_health_facts.py @@ -45,10 +45,7 @@ - "Example: `10.0.0.3:8080`" type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_backend_set.py b/plugins/modules/oci_loadbalancer_backend_set.py index f77b74c122..8565b42804 100644 --- a/plugins/modules/oci_loadbalancer_backend_set.py +++ b/plugins/modules/oci_loadbalancer_backend_set.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a BackendSet resource in Oracle Cloud Infrastructure - For I(state=present), adds a backend set to a load balancer. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: name: description: @@ -193,10 +194,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -505,29 +502,23 @@ def get_resource(self): backend_set_name=self.module.params.get("name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "load_balancer_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_backend_sets, **kwargs ) diff --git a/plugins/modules/oci_loadbalancer_backend_set_facts.py b/plugins/modules/oci_loadbalancer_backend_set_facts.py index e200fd87bd..8a4ba5142b 100644 --- a/plugins/modules/oci_loadbalancer_backend_set_facts.py +++ b/plugins/modules/oci_loadbalancer_backend_set_facts.py @@ -40,10 +40,7 @@ - Required to get a specific backend_set. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_backend_set_health_facts.py b/plugins/modules/oci_loadbalancer_backend_set_health_facts.py index b156e64bfd..996c0f6c7f 100644 --- a/plugins/modules/oci_loadbalancer_backend_set_health_facts.py +++ b/plugins/modules/oci_loadbalancer_backend_set_health_facts.py @@ -39,10 +39,7 @@ - "Example: `example_backend_set`" type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_certificate.py b/plugins/modules/oci_loadbalancer_certificate.py index e405b4f656..d1ff162d27 100644 --- a/plugins/modules/oci_loadbalancer_certificate.py +++ b/plugins/modules/oci_loadbalancer_certificate.py @@ -24,7 +24,8 @@ description: - This module allows the user to create and delete a Certificate resource in Oracle Cloud Infrastructure - For I(state=present), creates an asynchronous request to add an SSL certificate bundle. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: passphrase: description: @@ -90,10 +91,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -202,29 +199,23 @@ def get_resource(self): oci_common_utils.raise_does_not_exist_service_error() - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "load_balancer_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_certificates, **kwargs ) diff --git a/plugins/modules/oci_loadbalancer_certificate_facts.py b/plugins/modules/oci_loadbalancer_certificate_facts.py index 8e7bafb1db..58bd382605 100644 --- a/plugins/modules/oci_loadbalancer_certificate_facts.py +++ b/plugins/modules/oci_loadbalancer_certificate_facts.py @@ -37,10 +37,7 @@ - The name of the certificate whose details needs to be fetched. - Required to get a specific certificate. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_health_checker.py b/plugins/modules/oci_loadbalancer_health_checker.py index e1d0b6c29a..3b14161cf2 100644 --- a/plugins/modules/oci_loadbalancer_health_checker.py +++ b/plugins/modules/oci_loadbalancer_health_checker.py @@ -23,7 +23,8 @@ short_description: Manage a HealthChecker resource in Oracle Cloud Infrastructure description: - This module allows the user to update a HealthChecker resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: protocol: description: @@ -95,10 +96,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_loadbalancer_health_checker_facts.py b/plugins/modules/oci_loadbalancer_health_checker_facts.py index 7913699d54..d489e911d8 100644 --- a/plugins/modules/oci_loadbalancer_health_checker_facts.py +++ b/plugins/modules/oci_loadbalancer_health_checker_facts.py @@ -39,10 +39,7 @@ - "Example: `example_backend_set`" type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_health_facts.py b/plugins/modules/oci_loadbalancer_health_facts.py index 07ffe6b55d..10e2dce83e 100644 --- a/plugins/modules/oci_loadbalancer_health_facts.py +++ b/plugins/modules/oci_loadbalancer_health_facts.py @@ -40,10 +40,7 @@ - Required to list multiple load_balancer_healths. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_hostname.py b/plugins/modules/oci_loadbalancer_hostname.py index 5f26895a7f..36a9e52e4d 100644 --- a/plugins/modules/oci_loadbalancer_hostname.py +++ b/plugins/modules/oci_loadbalancer_hostname.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a Hostname resource in Oracle Cloud Infrastructure - For I(state=present), adds a hostname resource to the specified load balancer. For more information, see L(Managing Request Routing,https://docs.cloud.oracle.com/Content/Balance/Tasks/managingrequest.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: name: description: @@ -56,10 +57,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -151,29 +148,23 @@ def get_resource(self): name=self.module.params.get("name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "load_balancer_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_hostnames, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_loadbalancer_hostname_facts.py b/plugins/modules/oci_loadbalancer_hostname_facts.py index 123c0d357b..0296857b30 100644 --- a/plugins/modules/oci_loadbalancer_hostname_facts.py +++ b/plugins/modules/oci_loadbalancer_hostname_facts.py @@ -39,10 +39,7 @@ - "Example: `example_hostname_001`" - Required to get a specific hostname. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_listener.py b/plugins/modules/oci_loadbalancer_listener.py index 41e2fa7895..2bebb7d6c0 100644 --- a/plugins/modules/oci_loadbalancer_listener.py +++ b/plugins/modules/oci_loadbalancer_listener.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a Listener resource in Oracle Cloud Infrastructure - For I(state=present), adds a listener to a load balancer. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: default_backend_set_name: description: @@ -121,10 +122,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_loadbalancer_load_balancer.py b/plugins/modules/oci_loadbalancer_load_balancer.py index 42924643ff..ec90ceac5e 100644 --- a/plugins/modules/oci_loadbalancer_load_balancer.py +++ b/plugins/modules/oci_loadbalancer_load_balancer.py @@ -44,7 +44,8 @@ object, first make sure its state has changed to RUNNING. - When you create a load balancer, the system assigns an IP address. To get the IP address, use the L(GetLoadBalancer,https://docs.cloud.oracle.com/#/en/loadbalancer/20170115/LoadBalancer/GetLoadBalancer) operation. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -114,10 +115,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -879,31 +876,36 @@ def get_resource(self): load_balancer_id=self.module.params.get("load_balancer_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_load_balancers, **kwargs ) diff --git a/plugins/modules/oci_loadbalancer_load_balancer_facts.py b/plugins/modules/oci_loadbalancer_load_balancer_facts.py index 2ac9210721..e152e684d5 100644 --- a/plugins/modules/oci_loadbalancer_load_balancer_facts.py +++ b/plugins/modules/oci_loadbalancer_load_balancer_facts.py @@ -75,10 +75,7 @@ - "ACTIVE" - "DELETING" - "DELETED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_path_route_set.py b/plugins/modules/oci_loadbalancer_path_route_set.py index c623e7229a..0f83dabb44 100644 --- a/plugins/modules/oci_loadbalancer_path_route_set.py +++ b/plugins/modules/oci_loadbalancer_path_route_set.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a PathRouteSet resource in Oracle Cloud Infrastructure - For I(state=present), adds a path route set to a load balancer. For more information, see L(Managing Request Routing,https://docs.cloud.oracle.com/Content/Balance/Tasks/managingrequest.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: name: description: @@ -95,10 +96,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -239,29 +236,23 @@ def get_resource(self): path_route_set_name=self.module.params.get("name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "load_balancer_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_path_route_sets, **kwargs ) diff --git a/plugins/modules/oci_loadbalancer_path_route_set_facts.py b/plugins/modules/oci_loadbalancer_path_route_set_facts.py index 0cbd3285fa..7b52b1e9d5 100644 --- a/plugins/modules/oci_loadbalancer_path_route_set_facts.py +++ b/plugins/modules/oci_loadbalancer_path_route_set_facts.py @@ -40,10 +40,7 @@ - Required to get a specific path_route_set. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_policy_facts.py b/plugins/modules/oci_loadbalancer_policy_facts.py index a1052961d5..09ed85137a 100644 --- a/plugins/modules/oci_loadbalancer_policy_facts.py +++ b/plugins/modules/oci_loadbalancer_policy_facts.py @@ -33,10 +33,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_loadbalancer_protocol_facts.py b/plugins/modules/oci_loadbalancer_protocol_facts.py index b6078d52f8..edb5e4f1ca 100644 --- a/plugins/modules/oci_loadbalancer_protocol_facts.py +++ b/plugins/modules/oci_loadbalancer_protocol_facts.py @@ -33,10 +33,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_loadbalancer_rule_set.py b/plugins/modules/oci_loadbalancer_rule_set.py index 089e85eed5..a7e5036035 100644 --- a/plugins/modules/oci_loadbalancer_rule_set.py +++ b/plugins/modules/oci_loadbalancer_rule_set.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a RuleSet resource in Oracle Cloud Infrastructure - For I(state=present), creates a new rule set associated with the specified load balancer. For more information, see L(Managing Rule Sets,https://docs.cloud.oracle.com/Content/Balance/Tasks/managingrulesets.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: load_balancer_id: description: @@ -90,10 +91,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -237,29 +234,23 @@ def get_resource(self): rule_set_name=self.module.params.get("name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "load_balancer_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_rule_sets, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_loadbalancer_rule_set_facts.py b/plugins/modules/oci_loadbalancer_rule_set_facts.py index 0412c9d63c..c5facbed66 100644 --- a/plugins/modules/oci_loadbalancer_rule_set_facts.py +++ b/plugins/modules/oci_loadbalancer_rule_set_facts.py @@ -39,10 +39,7 @@ - Required to get a specific rule_set. type: str aliases: ["name"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_loadbalancer_shape_facts.py b/plugins/modules/oci_loadbalancer_shape_facts.py index 47e24ab73a..60dcbff1d3 100644 --- a/plugins/modules/oci_loadbalancer_shape_facts.py +++ b/plugins/modules/oci_loadbalancer_shape_facts.py @@ -32,10 +32,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_marketplace_accepted_agreement.py b/plugins/modules/oci_marketplace_accepted_agreement.py new file mode 100644 index 0000000000..1214e64022 --- /dev/null +++ b/plugins/modules/oci_marketplace_accepted_agreement.py @@ -0,0 +1,394 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_marketplace_accepted_agreement +short_description: Manage an AcceptedAgreement resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete an AcceptedAgreement resource in Oracle Cloud Infrastructure + - For I(state=present), accepts a terms of use agreement for a specific package version of a listing. You must accept all + terms of use for a package before you can deploy the package. +version_added: "2.9" +author: Oracle (@oracle) +options: + display_name: + description: + - A display name for the accepted agreement. + - Required for create, update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + aliases: ["name"] + compartment_id: + description: + - The unique identifier for the compartment where the agreement will be accepted. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + listing_id: + description: + - The unique identifier for the listing associated with the agreement. + - Required for create using I(state=present). + type: str + package_version: + description: + - The package version associated with the agreement. + - Required for create using I(state=present). + type: str + agreement_id: + description: + - The agreement to accept. + - Required for create using I(state=present). + type: str + signature: + description: + - A signature generated for the listing package agreements that you can retrieve + with L(GetAgreement,https://docs.cloud.oracle.com/api/#/en/marketplace/20181001/Agreement/GetAgreement). + - Required for create using I(state=present). + type: str + defined_tags: + description: + - "The defined tags associated with this resource, if any. Each key is predefined and scoped to namespaces. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + freeform_tags: + description: + - "The freeform tags associated with this resource, if any. Each tag is a simple key-value pair with no + predefined name, type, or namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + accepted_agreement_id: + description: + - The unique identifier for the accepted terms of use agreement. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the AcceptedAgreement. + - Use I(state=present) to create or update an AcceptedAgreement. + - Use I(state=absent) to delete an AcceptedAgreement. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] +""" + +EXAMPLES = """ +- name: Create accepted_agreement + oci_marketplace_accepted_agreement: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + listing_id: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + package_version: package_version_example + agreement_id: ocid1.agreement.oc1..xxxxxxEXAMPLExxxxxx + signature: signature_example + +- name: Update accepted_agreement using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_marketplace_accepted_agreement: + display_name: display_name_example + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + defined_tags: {'Operations': {'CostCenter': 'US'}} + freeform_tags: {'Department': 'Finance'} + +- name: Update accepted_agreement + oci_marketplace_accepted_agreement: + display_name: display_name_example + defined_tags: {'Operations': {'CostCenter': 'US'}} + accepted_agreement_id: ocid1.acceptedagreement.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete accepted_agreement + oci_marketplace_accepted_agreement: + accepted_agreement_id: ocid1.acceptedagreement.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete accepted_agreement using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_marketplace_accepted_agreement: + display_name: display_name_example + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +accepted_agreement: + description: + - Details of the AcceptedAgreement resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The unique identifier for the acceptance of the agreement within a specific compartment. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - A display name for the accepted agreement. + returned: on success + type: string + sample: display_name_example + compartment_id: + description: + - The unique identifier for the compartment where the agreement was accepted. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + listing_id: + description: + - The unique identifier for the listing associated with the agreement. + returned: on success + type: string + sample: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + package_version: + description: + - The package version associated with the agreement. + returned: on success + type: string + sample: package_version_example + agreement_id: + description: + - The unique identifier for the terms of use agreement itself. + returned: on success + type: string + sample: ocid1.agreement.oc1..xxxxxxEXAMPLExxxxxx + time_accepted: + description: + - The time the agreement was accepted. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + defined_tags: + description: + - "The defined tags associated with this resource, if any. Each key is predefined and scoped to namespaces. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + freeform_tags: + description: + - "The freeform tags associated with this resource, if any. Each tag is a simple key-value pair with no + predefined name, type, or namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "listing_id": "ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx", + "package_version": "package_version_example", + "agreement_id": "ocid1.agreement.oc1..xxxxxxEXAMPLExxxxxx", + "time_accepted": "2013-10-20T19:20:30+01:00", + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "freeform_tags": {'Department': 'Finance'} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.marketplace import MarketplaceClient + from oci.marketplace.models import CreateAcceptedAgreementDetails + from oci.marketplace.models import UpdateAcceptedAgreementDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class AcceptedAgreementHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "accepted_agreement_id" + + def get_module_resource_id(self): + return self.module.params.get("accepted_agreement_id") + + def get_get_fn(self): + return self.client.get_accepted_agreement + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_accepted_agreement, + accepted_agreement_id=self.module.params.get("accepted_agreement_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = [ + "display_name", + "listing_id", + "package_version", + "accepted_agreement_id", + ] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_accepted_agreements, **kwargs + ) + + def get_create_model_class(self): + return CreateAcceptedAgreementDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_accepted_agreement, + call_fn_args=(), + call_fn_kwargs=dict(create_accepted_agreement_details=create_details,), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateAcceptedAgreementDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_accepted_agreement, + call_fn_args=(), + call_fn_kwargs=dict( + accepted_agreement_id=self.module.params.get("accepted_agreement_id"), + update_accepted_agreement_details=update_details, + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_accepted_agreement, + call_fn_args=(), + call_fn_kwargs=dict( + accepted_agreement_id=self.module.params.get("accepted_agreement_id"), + signature=self.module.params.get("signature"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +AcceptedAgreementHelperCustom = get_custom_class("AcceptedAgreementHelperCustom") + + +class ResourceHelper(AcceptedAgreementHelperCustom, AcceptedAgreementHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=False + ) + module_args.update( + dict( + display_name=dict(aliases=["name"], type="str"), + compartment_id=dict(type="str"), + listing_id=dict(type="str"), + package_version=dict(type="str"), + agreement_id=dict(type="str"), + signature=dict(type="str"), + defined_tags=dict(type="dict"), + freeform_tags=dict(type="dict"), + accepted_agreement_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="accepted_agreement", + service_client_class=MarketplaceClient, + namespace="marketplace", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_marketplace_accepted_agreement_facts.py b/plugins/modules/oci_marketplace_accepted_agreement_facts.py new file mode 100644 index 0000000000..ad97be601c --- /dev/null +++ b/plugins/modules/oci_marketplace_accepted_agreement_facts.py @@ -0,0 +1,269 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_marketplace_accepted_agreement_facts +short_description: Fetches details about one or multiple AcceptedAgreement resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple AcceptedAgreement resources in Oracle Cloud Infrastructure + - Lists the terms of use agreements that have been accepted in the specified compartment. + You can filter results by specifying query parameters. + - If I(accepted_agreement_id) is specified, the details of a single AcceptedAgreement will be returned. +version_added: "2.5" +options: + accepted_agreement_id: + description: + - The unique identifier for the accepted terms of use agreement. + - Required to get a specific accepted_agreement. + type: str + aliases: ["id"] + compartment_id: + description: + - The unique identifier for the compartment. + - Required to list multiple accepted_agreements. + type: str + display_name: + description: + - The display name of the resource. + type: str + aliases: ["name"] + listing_id: + description: + - The unique identifier for the listing. + type: str + package_version: + description: + - The version of the package. Package versions are unique within a listing. + type: str + sort_by: + description: + - The field to use to sort listed results. You can only specify one field to sort by. + `TIMEACCEPTED` displays results in descending order by default. You can change your + preference by specifying a different sort order. + type: str + choices: + - "TIMEACCEPTED" + sort_order: + description: + - The sort order to use, either `ASC` or `DESC`. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List accepted_agreements + oci_marketplace_accepted_agreement_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific accepted_agreement + oci_marketplace_accepted_agreement_facts: + accepted_agreement_id: ocid1.acceptedagreement.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +accepted_agreements: + description: + - List of AcceptedAgreement resources + returned: on success + type: complex + contains: + id: + description: + - The unique identifier for the acceptance of the agreement within a specific compartment. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - A display name for the accepted agreement. + returned: on success + type: string + sample: display_name_example + compartment_id: + description: + - The unique identifier for the compartment where the agreement was accepted. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + listing_id: + description: + - The unique identifier for the listing associated with the agreement. + returned: on success + type: string + sample: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + package_version: + description: + - The package version associated with the agreement. + returned: on success + type: string + sample: package_version_example + agreement_id: + description: + - The unique identifier for the terms of use agreement itself. + returned: on success + type: string + sample: ocid1.agreement.oc1..xxxxxxEXAMPLExxxxxx + time_accepted: + description: + - The time the agreement was accepted. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + defined_tags: + description: + - "The defined tags associated with this resource, if any. Each key is predefined and scoped to namespaces. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + freeform_tags: + description: + - "The freeform tags associated with this resource, if any. Each tag is a simple key-value pair with no + predefined name, type, or namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). + Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "display_name_example", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "listing_id": "ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx", + "package_version": "package_version_example", + "agreement_id": "ocid1.agreement.oc1..xxxxxxEXAMPLExxxxxx", + "time_accepted": "2013-10-20T19:20:30+01:00", + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "freeform_tags": {'Department': 'Finance'} + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.marketplace import MarketplaceClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class AcceptedAgreementFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "accepted_agreement_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_accepted_agreement, + accepted_agreement_id=self.module.params.get("accepted_agreement_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "display_name", + "listing_id", + "package_version", + "accepted_agreement_id", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_accepted_agreements, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +AcceptedAgreementFactsHelperCustom = get_custom_class( + "AcceptedAgreementFactsHelperCustom" +) + + +class ResourceFactsHelper( + AcceptedAgreementFactsHelperCustom, AcceptedAgreementFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + accepted_agreement_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + display_name=dict(aliases=["name"], type="str"), + listing_id=dict(type="str"), + package_version=dict(type="str"), + sort_by=dict(type="str", choices=["TIMEACCEPTED"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="accepted_agreement", + service_client_class=MarketplaceClient, + namespace="marketplace", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(accepted_agreements=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_marketplace_agreement_facts.py b/plugins/modules/oci_marketplace_agreement_facts.py new file mode 100644 index 0000000000..138cb0d703 --- /dev/null +++ b/plugins/modules/oci_marketplace_agreement_facts.py @@ -0,0 +1,230 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_marketplace_agreement_facts +short_description: Fetches details about one or multiple Agreement resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Agreement resources in Oracle Cloud Infrastructure + - Returns the terms of use agreements that must be accepted before you can deploy the specified version of a package. + - If I(agreement_id) is specified, the details of a single Agreement will be returned. +version_added: "2.5" +options: + listing_id: + description: + - The unique identifier for the listing. + type: str + required: true + package_version: + description: + - The version of the package. Package versions are unique within a listing. + type: str + required: true + agreement_id: + description: + - The unique identifier for the agreement. + - Required to get a specific agreement. + type: str + aliases: ["id"] + compartment_id: + description: + - The unique identifier for the compartment. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List agreements + oci_marketplace_agreement_facts: + listing_id: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + package_version: package_version_example + +- name: Get a specific agreement + oci_marketplace_agreement_facts: + listing_id: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + package_version: package_version_example + agreement_id: ocid1.agreement.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +agreements: + description: + - List of Agreement resources + returned: on success + type: complex + contains: + id: + description: + - The unique identifier for the agreement. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + content_url: + description: + - The content URL of the agreement. + returned: on success + type: string + sample: content_url_example + signature: + description: + - A time-based signature that can be used to accept an agreement or remove a + previously accepted agreement from the list that Marketplace checks before a deployment. + returned: on success + type: string + sample: signature_example + compartment_id: + description: + - The unique identifier for the compartment. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + author: + description: + - Who authored the agreement. + returned: on success + type: string + sample: ORACLE + prompt: + description: + - Textual prompt to read and accept the agreement. + returned: on success + type: string + sample: prompt_example + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "content_url": "content_url_example", + "signature": "signature_example", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "author": "ORACLE", + "prompt": "prompt_example" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.marketplace import MarketplaceClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class AgreementFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "listing_id", + "package_version", + "agreement_id", + ] + + def get_required_params_for_list(self): + return [ + "listing_id", + "package_version", + ] + + def get_resource(self): + optional_get_method_params = [ + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_agreement, + listing_id=self.module.params.get("listing_id"), + package_version=self.module.params.get("package_version"), + agreement_id=self.module.params.get("agreement_id"), + **optional_kwargs + ) + + def list_resources(self): + optional_list_method_params = [ + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_agreements, + listing_id=self.module.params.get("listing_id"), + package_version=self.module.params.get("package_version"), + **optional_kwargs + ) + + +AgreementFactsHelperCustom = get_custom_class("AgreementFactsHelperCustom") + + +class ResourceFactsHelper(AgreementFactsHelperCustom, AgreementFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + listing_id=dict(type="str", required=True), + package_version=dict(type="str", required=True), + agreement_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="agreement", + service_client_class=MarketplaceClient, + namespace="marketplace", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(agreements=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_marketplace_category_facts.py b/plugins/modules/oci_marketplace_category_facts.py new file mode 100644 index 0000000000..a963f3774b --- /dev/null +++ b/plugins/modules/oci_marketplace_category_facts.py @@ -0,0 +1,135 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_marketplace_category_facts +short_description: Fetches details about one or multiple Category resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Category resources in Oracle Cloud Infrastructure + - Gets the list of all the categories for listings published to Oracle Cloud Infrastructure Marketplace. Categories apply + to the software product provided by the listing. +version_added: "2.5" +options: + compartment_id: + description: + - The unique identifier for the compartment. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] +""" + +EXAMPLES = """ +- name: List categories + oci_marketplace_category_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +categories: + description: + - List of Category resources + returned: on success + type: complex + contains: + name: + description: + - Name of the product category. + returned: on success + type: string + sample: name_example + sample: [{ + "name": "name_example" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.marketplace import MarketplaceClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class CategoryFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: list""" + + def get_required_params_for_list(self): + return [] + + def list_resources(self): + optional_list_method_params = [ + "compartment_id", + "name", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_categories, **optional_kwargs + ) + + +CategoryFactsHelperCustom = get_custom_class("CategoryFactsHelperCustom") + + +class ResourceFactsHelper(CategoryFactsHelperCustom, CategoryFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update(dict(compartment_id=dict(type="str"), name=dict(type="str"),)) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="category", + service_client_class=MarketplaceClient, + namespace="marketplace", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(categories=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_marketplace_listing_facts.py b/plugins/modules/oci_marketplace_listing_facts.py new file mode 100644 index 0000000000..94547567fb --- /dev/null +++ b/plugins/modules/oci_marketplace_listing_facts.py @@ -0,0 +1,793 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_marketplace_listing_facts +short_description: Fetches details about one or multiple Listing resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Listing resources in Oracle Cloud Infrastructure + - Gets a list of listings from Oracle Cloud Infrastructure Marketplace by searching keywords and + filtering according to listing attributes. + - If you plan to launch an instance from an image listing, you must first subscribe to the listing. When + you launch the instance, you also need to provide the image ID of the listing resource version that you want. + - Subscribing to the listing requires you to first get a signature from the terms of use agreement for the + listing resource version. To get the signature, issue a L(GetAppCatalogListingAgreements,https://docs.cloud.oracle.com/en- + us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersionAgreements/GetAppCatalogListingAgreements) API call. + The L(AppCatalogListingResourceVersionAgreements,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersionAgreements) + object, including + its signature, is returned in the response. With the signature for the terms of use agreement for the desired + listing resource version, create a subscription by issuing a + L(CreateAppCatalogSubscription,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogSubscription/CreateAppCatalogSubscription) API + call. + - To get the image ID to launch an instance, issue a L(GetAppCatalogListingResourceVersion,https://docs.cloud.oracle.com/en- + us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersion/GetAppCatalogListingResourceVersion) API call. + Lastly, to launch the instance, use the image ID of the listing resource version to issue a L(LaunchInstance,https://docs.cloud.oracle.com/en- + us/iaas/api/#/en/iaas/latest/Instance/LaunchInstance) API call. + - If I(listing_id) is specified, the details of a single Listing will be returned. +version_added: "2.5" +options: + listing_id: + description: + - The unique identifier for the listing. + - Required to get a specific listing. + type: str + aliases: ["id"] + compartment_id: + description: + - The unique identifier for the compartment. + type: str + name: + description: + - The name of the listing. + type: list + publisher_id: + description: + - Limit results to just this publisher. + type: str + package_type: + description: + - A filter to return only packages that match the given package type exactly. + type: str + sort_by: + description: + - The field to use to sort listed results. You can only specify one field to sort by. + `TIMERELEASED` displays results in descending order by default. + You can change your preference by specifying a different sort order. + type: str + choices: + - "TIMERELEASED" + sort_order: + description: + - The sort order to use, either `ASC` or `DESC`. + type: str + choices: + - "ASC" + - "DESC" + category: + description: + - Name of the product category or categories. If you specify multiple categories, then Marketplace returns any listing with + one or more matching categories. + type: list + pricing: + description: + - Name of the pricing type. If multiple pricing types are provided, then any listing with + one or more matching pricing models will be returned. + type: list + choices: + - "FREE" + - "BYOL" + - "PAYGO" + is_featured: + description: + - Indicates whether to show only featured listings. If this is set to `false` or is omitted, then all listings will be returned. + type: bool +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List listings + oci_marketplace_listing_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific listing + oci_marketplace_listing_facts: + listing_id: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +listings: + description: + - List of Listing resources + returned: on success + type: complex + contains: + id: + description: + - The unique identifier for the listing in Marketplace. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + name: + description: + - The name of the listing. + returned: on success + type: string + sample: name_example + version: + description: + - The version of the listing. + returned: on success + type: string + sample: version_example + tagline: + description: + - The tagline of the listing. + returned: on success + type: string + sample: tagline_example + keywords: + description: + - Keywords associated with the listing. + returned: on success + type: string + sample: keywords_example + short_description: + description: + - A short description of the listing. + returned: on success + type: string + sample: short_description_example + usage_information: + description: + - Usage information for the listing. + returned: on success + type: string + sample: usage_information_example + long_description: + description: + - A long description of the listing. + returned: on success + type: string + sample: long_description_example + license_model_description: + description: + - A description of the publisher's licensing model for the listing. + returned: on success + type: string + sample: license_model_description_example + system_requirements: + description: + - System requirements for the listing. + returned: on success + type: string + sample: system_requirements_example + time_released: + description: + - The release date of the listing. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + release_notes: + description: + - Release notes for the listing. + returned: on success + type: string + sample: release_notes_example + categories: + description: + - Categories that the listing belongs to. + returned: on success + type: list + sample: [] + publisher: + description: + - "" + returned: on success + type: complex + contains: + id: + description: + - Unique identifier for the publisher. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + name: + description: + - The name of the publisher. + returned: on success + type: string + sample: name_example + description: + description: + - A description of the publisher. + returned: on success + type: string + sample: description_example + year_founded: + description: + - The year the publisher's company or organization was founded. + returned: on success + type: int + sample: 56 + website_url: + description: + - The publisher's website. + returned: on success + type: string + sample: website_url_example + contact_email: + description: + - The email address of the publisher. + returned: on success + type: string + sample: contact_email_example + contact_phone: + description: + - The phone number of the publisher. + returned: on success + type: string + sample: contact_phone_example + hq_address: + description: + - The address of the publisher's headquarters. + returned: on success + type: string + sample: hq_address_example + logo: + description: + - "" + returned: on success + type: complex + contains: + name: + description: + - The name used to refer to the upload data. + returned: on success + type: string + sample: name_example + content_url: + description: + - The content URL of the upload data. + returned: on success + type: string + sample: content_url_example + mime_type: + description: + - The MIME type of the upload data. + returned: on success + type: string + sample: mime_type_example + file_extension: + description: + - The file extension of the upload data. + returned: on success + type: string + sample: file_extension_example + links: + description: + - Reference links. + returned: on success + type: complex + contains: + rel: + description: + - Reference links to the previous page, next page, and other pages. + returned: on success + type: string + sample: SELF + href: + description: + - The anchor tag. + returned: on success + type: string + sample: href_example + languages: + description: + - Languages supported by the listing. + returned: on success + type: complex + contains: + name: + description: + - The name of the item. + returned: on success + type: string + sample: name_example + code: + description: + - A code assigned to the item. + returned: on success + type: string + sample: code_example + screenshots: + description: + - Screenshots of the listing. + returned: on success + type: complex + contains: + name: + description: + - The name of the screenshot. + returned: on success + type: string + sample: name_example + description: + description: + - A description of the screenshot. + returned: on success + type: string + sample: description_example + content_url: + description: + - The content URL of the screenshot. + returned: on success + type: string + sample: content_url_example + mime_type: + description: + - The MIME type of the screenshot. + returned: on success + type: string + sample: mime_type_example + file_extension: + description: + - The file extension of the screenshot. + returned: on success + type: string + sample: file_extension_example + videos: + description: + - Videos of the listing. + returned: on success + type: complex + contains: + name: + description: + - Text that describes the resource. + returned: on success + type: string + sample: name_example + url: + description: + - The URL of the resource. + returned: on success + type: string + sample: url_example + support_contacts: + description: + - Contact information to use to get support from the publisher for the listing. + returned: on success + type: complex + contains: + name: + description: + - The name of the contact. + returned: on success + type: string + sample: name_example + phone: + description: + - The phone number of the contact. + returned: on success + type: string + sample: phone_example + email: + description: + - The email of the contact. + returned: on success + type: string + sample: email_example + subject: + description: + - The email subject line to use when contacting support. + returned: on success + type: string + sample: subject_example + support_links: + description: + - Links to support resources for the listing. + returned: on success + type: complex + contains: + name: + description: + - Text that describes the resource. + returned: on success + type: string + sample: name_example + url: + description: + - The URL of the resource. + returned: on success + type: string + sample: url_example + documentation_links: + description: + - Links to additional documentation provided by the publisher specifically for the listing. + returned: on success + type: complex + contains: + name: + description: + - Text that describes the resource. + returned: on success + type: string + sample: name_example + url: + description: + - The URL of the resource. + returned: on success + type: string + sample: url_example + document_category: + description: + - The category that the document belongs to. + returned: on success + type: string + sample: document_category_example + icon: + description: + - "" + returned: on success + type: complex + contains: + name: + description: + - The name used to refer to the upload data. + returned: on success + type: string + sample: name_example + content_url: + description: + - The content URL of the upload data. + returned: on success + type: string + sample: content_url_example + mime_type: + description: + - The MIME type of the upload data. + returned: on success + type: string + sample: mime_type_example + file_extension: + description: + - The file extension of the upload data. + returned: on success + type: string + sample: file_extension_example + banner: + description: + - "" + returned: on success + type: complex + contains: + name: + description: + - The name used to refer to the upload data. + returned: on success + type: string + sample: name_example + content_url: + description: + - The content URL of the upload data. + returned: on success + type: string + sample: content_url_example + mime_type: + description: + - The MIME type of the upload data. + returned: on success + type: string + sample: mime_type_example + file_extension: + description: + - The file extension of the upload data. + returned: on success + type: string + sample: file_extension_example + regions: + description: + - The regions where the listing is eligible to be deployed. + returned: on success + type: complex + contains: + name: + description: + - The name of the region. + returned: on success + type: string + sample: name_example + code: + description: + - The code of the region. + returned: on success + type: string + sample: code_example + countries: + description: + - Countries in the region. + returned: on success + type: complex + contains: + name: + description: + - The name of the item. + returned: on success + type: string + sample: name_example + code: + description: + - A code assigned to the item. + returned: on success + type: string + sample: code_example + package_type: + description: + - The listing's package type. + returned: on success + type: string + sample: ORCHESTRATION + default_package_version: + description: + - The default package version. + returned: on success + type: string + sample: default_package_version_example + links: + description: + - Links to reference material. + returned: on success + type: complex + contains: + rel: + description: + - Reference links to the previous page, next page, and other pages. + returned: on success + type: string + sample: SELF + href: + description: + - The anchor tag. + returned: on success + type: string + sample: href_example + is_featured: + description: + - Indicates whether the listing is included in Featured Listings. + returned: on success + type: bool + sample: true + pricing_types: + description: + - Summary of the pricing types available across all packages in the listing. + returned: on success + type: list + sample: [] + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "name": "name_example", + "version": "version_example", + "tagline": "tagline_example", + "keywords": "keywords_example", + "short_description": "short_description_example", + "usage_information": "usage_information_example", + "long_description": "long_description_example", + "license_model_description": "license_model_description_example", + "system_requirements": "system_requirements_example", + "time_released": "2013-10-20T19:20:30+01:00", + "release_notes": "release_notes_example", + "categories": [], + "publisher": { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "name": "name_example", + "description": "description_example", + "year_founded": 56, + "website_url": "website_url_example", + "contact_email": "contact_email_example", + "contact_phone": "contact_phone_example", + "hq_address": "hq_address_example", + "logo": { + "name": "name_example", + "content_url": "content_url_example", + "mime_type": "mime_type_example", + "file_extension": "file_extension_example" + }, + "links": [{ + "rel": "SELF", + "href": "href_example" + }] + }, + "languages": [{ + "name": "name_example", + "code": "code_example" + }], + "screenshots": [{ + "name": "name_example", + "description": "description_example", + "content_url": "content_url_example", + "mime_type": "mime_type_example", + "file_extension": "file_extension_example" + }], + "videos": [{ + "name": "name_example", + "url": "url_example" + }], + "support_contacts": [{ + "name": "name_example", + "phone": "phone_example", + "email": "email_example", + "subject": "subject_example" + }], + "support_links": [{ + "name": "name_example", + "url": "url_example" + }], + "documentation_links": [{ + "name": "name_example", + "url": "url_example", + "document_category": "document_category_example" + }], + "icon": { + "name": "name_example", + "content_url": "content_url_example", + "mime_type": "mime_type_example", + "file_extension": "file_extension_example" + }, + "banner": { + "name": "name_example", + "content_url": "content_url_example", + "mime_type": "mime_type_example", + "file_extension": "file_extension_example" + }, + "regions": [{ + "name": "name_example", + "code": "code_example", + "countries": [{ + "name": "name_example", + "code": "code_example" + }] + }], + "package_type": "ORCHESTRATION", + "default_package_version": "default_package_version_example", + "links": [{ + "rel": "SELF", + "href": "href_example" + }], + "is_featured": true, + "pricing_types": [] + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.marketplace import MarketplaceClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ListingFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "listing_id", + ] + + def get_required_params_for_list(self): + return [] + + def get_resource(self): + optional_get_method_params = [ + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_listing, + listing_id=self.module.params.get("listing_id"), + **optional_kwargs + ) + + def list_resources(self): + optional_list_method_params = [ + "name", + "listing_id", + "publisher_id", + "package_type", + "sort_by", + "sort_order", + "category", + "pricing", + "is_featured", + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_listings, **optional_kwargs + ) + + +ListingFactsHelperCustom = get_custom_class("ListingFactsHelperCustom") + + +class ResourceFactsHelper(ListingFactsHelperCustom, ListingFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + listing_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + name=dict(type="list"), + publisher_id=dict(type="str"), + package_type=dict(type="str"), + sort_by=dict(type="str", choices=["TIMERELEASED"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + category=dict(type="list"), + pricing=dict(type="list", choices=["FREE", "BYOL", "PAYGO"]), + is_featured=dict(type="bool"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="listing", + service_client_class=MarketplaceClient, + namespace="marketplace", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(listings=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_marketplace_listing_package_facts.py b/plugins/modules/oci_marketplace_listing_package_facts.py new file mode 100644 index 0000000000..636aa087e4 --- /dev/null +++ b/plugins/modules/oci_marketplace_listing_package_facts.py @@ -0,0 +1,427 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_marketplace_listing_package_facts +short_description: Fetches details about one or multiple ListingPackage resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple ListingPackage resources in Oracle Cloud Infrastructure + - Gets the list of packages for a listing. + - If you plan to launch an instance from an image listing, you must first subscribe to the listing. When + you launch the instance, you also need to provide the image ID of the listing resource version that you want. + - Subscribing to the listing requires you to first get a signature from the terms of use agreement for the + listing resource version. To get the signature, issue a L(GetAppCatalogListingAgreements,https://docs.cloud.oracle.com/en- + us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersionAgreements/GetAppCatalogListingAgreements) API call. + The L(AppCatalogListingResourceVersionAgreements,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersionAgreements) + object, including + its signature, is returned in the response. With the signature for the terms of use agreement for the desired + listing resource version, create a subscription by issuing a + L(CreateAppCatalogSubscription,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogSubscription/CreateAppCatalogSubscription) API + call. + - To get the image ID to launch an instance, issue a L(GetAppCatalogListingResourceVersion,https://docs.cloud.oracle.com/en- + us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersion/GetAppCatalogListingResourceVersion) API call. + Lastly, to launch the instance, use the image ID of the listing resource version to issue a L(LaunchInstance,https://docs.cloud.oracle.com/en- + us/iaas/api/#/en/iaas/latest/Instance/LaunchInstance) API call. + - If I(package_version) is specified, the details of a single ListingPackage will be returned. +version_added: "2.5" +options: + listing_id: + description: + - The unique identifier for the listing. + type: str + required: true + package_version: + description: + - The version of the package. Package versions are unique within a listing. + - Required to get a specific listing_package. + type: str + compartment_id: + description: + - The unique identifier for the compartment. + type: str + package_type: + description: + - A filter to return only packages that match the given package type exactly. + type: str + sort_by: + description: + - The field to use to sort listed results. You can only specify one field to sort by. + `TIMERELEASED` displays results in descending order by default. + You can change your preference by specifying a different sort order. + type: str + choices: + - "TIMERELEASED" + sort_order: + description: + - The sort order to use, either `ASC` or `DESC`. + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List listing_packages + oci_marketplace_listing_package_facts: + listing_id: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific listing_package + oci_marketplace_listing_package_facts: + listing_id: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + package_version: package_version_example + +""" + +RETURN = """ +listing_packages: + description: + - List of ListingPackage resources + returned: on success + type: complex + contains: + description: + description: + - Description of this package. + returned: on success + type: string + sample: description_example + listing_id: + description: + - The ID of the listing this package belongs to. + returned: on success + type: string + sample: ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx + version: + description: + - The package version. + returned: on success + type: string + sample: version_example + package_type: + description: + - The specified package's type. + returned: on success + type: string + sample: ORCHESTRATION + pricing: + description: + - "" + returned: on success + type: complex + contains: + type: + description: + - The type of the pricing model. + returned: on success + type: string + sample: FREE + pay_go_strategy: + description: + - The type of pricing for a PAYGO model, eg PER_OCPU_LINEAR, PER_OCPU_MIN_BILLING, PER_INSTANCE. Null if type is not PAYGO. + returned: on success + type: string + sample: PER_OCPU_LINEAR + currency: + description: + - The currency of the pricing model. + returned: on success + type: string + sample: USD + rate: + description: + - The pricing rate. + returned: on success + type: float + sample: 10 + resource_id: + description: + - The unique identifier for the package resource. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + time_created: + description: + - The date and time this listing package was created, expressed in L(RFC 3339,https://tools.ietf.org/html/rfc3339) + timestamp format. + - "Example: `2016-08-25T21:10:29.600Z`" + returned: on success + type: string + sample: 2016-08-25T21:10:29.600Z + resource_link: + description: + - Link to the orchestration resource. + returned: on success + type: string + sample: resource_link_example + variables: + description: + - List of variables for the orchestration resource. + returned: on success + type: complex + contains: + name: + description: + - The name of the variable. + returned: on success + type: string + sample: name_example + default_value: + description: + - The variable's default value. + returned: on success + type: string + sample: default_value_example + description: + description: + - A description of the variable. + returned: on success + type: string + sample: description_example + data_type: + description: + - The data type of the variable. + returned: on success + type: string + sample: STRING + is_mandatory: + description: + - Whether the variable is mandatory. + returned: on success + type: bool + sample: true + hint_message: + description: + - A brief textual description that helps to explain the variable. + returned: on success + type: string + sample: hint_message_example + regions: + description: + - List of regions in which this ListingPackage is available. + returned: on success + type: complex + contains: + name: + description: + - The name of the region. + returned: on success + type: string + sample: name_example + code: + description: + - The code of the region. + returned: on success + type: string + sample: code_example + countries: + description: + - Countries in the region. + returned: on success + type: complex + contains: + name: + description: + - The name of the item. + returned: on success + type: string + sample: name_example + code: + description: + - A code assigned to the item. + returned: on success + type: string + sample: code_example + app_catalog_listing_id: + description: + - The ID of the listing resource associated with this listing package. For more information, see + L(AppCatalogListing,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogListing/) in the Core Services API. + returned: on success + type: string + sample: ocid1.appcataloglisting.oc1..xxxxxxEXAMPLExxxxxx + app_catalog_listing_resource_version: + description: + - The resource version of the listing resource associated with this listing package. + returned: on success + type: string + sample: app_catalog_listing_resource_version_example + image_id: + description: + - The id of the image corresponding to the package. + returned: on success + type: string + sample: ocid1.image.oc1..xxxxxxEXAMPLExxxxxx + package_version: + description: + - The version of the specified package. + returned: on success + type: string + sample: package_version_example + sample: [{ + "description": "description_example", + "listing_id": "ocid1.listing.oc1..xxxxxxEXAMPLExxxxxx", + "version": "version_example", + "package_type": "ORCHESTRATION", + "pricing": { + "type": "FREE", + "pay_go_strategy": "PER_OCPU_LINEAR", + "currency": "USD", + "rate": 10 + }, + "resource_id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "time_created": "2016-08-25T21:10:29.600Z", + "resource_link": "resource_link_example", + "variables": [{ + "name": "name_example", + "default_value": "default_value_example", + "description": "description_example", + "data_type": "STRING", + "is_mandatory": true, + "hint_message": "hint_message_example" + }], + "regions": [{ + "name": "name_example", + "code": "code_example", + "countries": [{ + "name": "name_example", + "code": "code_example" + }] + }], + "app_catalog_listing_id": "ocid1.appcataloglisting.oc1..xxxxxxEXAMPLExxxxxx", + "app_catalog_listing_resource_version": "app_catalog_listing_resource_version_example", + "image_id": "ocid1.image.oc1..xxxxxxEXAMPLExxxxxx", + "package_version": "package_version_example" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.marketplace import MarketplaceClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ListingPackageFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "listing_id", + "package_version", + ] + + def get_required_params_for_list(self): + return [ + "listing_id", + ] + + def get_resource(self): + optional_get_method_params = [ + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_package, + listing_id=self.module.params.get("listing_id"), + package_version=self.module.params.get("package_version"), + **optional_kwargs + ) + + def list_resources(self): + optional_list_method_params = [ + "package_version", + "package_type", + "sort_by", + "sort_order", + "compartment_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_packages, + listing_id=self.module.params.get("listing_id"), + **optional_kwargs + ) + + +ListingPackageFactsHelperCustom = get_custom_class("ListingPackageFactsHelperCustom") + + +class ResourceFactsHelper( + ListingPackageFactsHelperCustom, ListingPackageFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + listing_id=dict(type="str", required=True), + package_version=dict(type="str"), + compartment_id=dict(type="str"), + package_type=dict(type="str"), + sort_by=dict(type="str", choices=["TIMERELEASED"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="listing_package", + service_client_class=MarketplaceClient, + namespace="marketplace", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(listing_packages=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_marketplace_publisher_facts.py b/plugins/modules/oci_marketplace_publisher_facts.py new file mode 100644 index 0000000000..f42d055c59 --- /dev/null +++ b/plugins/modules/oci_marketplace_publisher_facts.py @@ -0,0 +1,159 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_marketplace_publisher_facts +short_description: Fetches details about one or multiple Publisher resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Publisher resources in Oracle Cloud Infrastructure + - Gets the list of all the publishers of listings available in Oracle Cloud Infrastructure Marketplace. +version_added: "2.5" +options: + publisher_id: + description: + - Limit results to just this publisher. + type: str + compartment_id: + description: + - The unique identifier for the compartment. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] +""" + +EXAMPLES = """ +- name: List publishers + oci_marketplace_publisher_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +publishers: + description: + - List of Publisher resources + returned: on success + type: complex + contains: + id: + description: + - Unique identifier for the publisher. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + name: + description: + - The name of the publisher. + returned: on success + type: string + sample: name_example + description: + description: + - A description of the publisher. + returned: on success + type: string + sample: description_example + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "name": "name_example", + "description": "description_example" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.marketplace import MarketplaceClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class PublisherFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: list""" + + def get_required_params_for_list(self): + return [] + + def list_resources(self): + optional_list_method_params = [ + "publisher_id", + "compartment_id", + "name", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_publishers, **optional_kwargs + ) + + +PublisherFactsHelperCustom = get_custom_class("PublisherFactsHelperCustom") + + +class ResourceFactsHelper(PublisherFactsHelperCustom, PublisherFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + publisher_id=dict(type="str"), + compartment_id=dict(type="str"), + name=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="publisher", + service_client_class=MarketplaceClient, + namespace="marketplace", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(publishers=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_alarm.py b/plugins/modules/oci_monitoring_alarm.py new file mode 100644 index 0000000000..06fed48501 --- /dev/null +++ b/plugins/modules/oci_monitoring_alarm.py @@ -0,0 +1,680 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_alarm +short_description: Manage an Alarm resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete an Alarm resource in Oracle Cloud Infrastructure + - For I(state=present), creates a new alarm in the specified compartment. + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + - This call is subject to a Monitoring limit that applies to the total number of requests across all alarm operations. + Monitoring might throttle this call to reject an otherwise valid request when the total rate of alarm operations exceeds 10 requests, + or transactions, per second (TPS) for a given tenancy. +version_added: "2.9" +author: Oracle (@oracle) +options: + display_name: + description: + - A user-friendly name for the alarm. It does not have to be unique, and it's changeable. + Avoid entering confidential information. + - This name is sent as the title for notifications related to this alarm. + - "Example: `High CPU Utilization`" + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + aliases: ["name"] + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the alarm. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + metric_compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the metric + being evaluated by the alarm. + - Required for create using I(state=present). + type: str + metric_compartment_id_in_subtree: + description: + - When true, the alarm evaluates metrics from all compartments and subcompartments. The parameter can + only be set to true when metricCompartmentId is the tenancy OCID (the tenancy is the root compartment). + A true value requires the user to have tenancy-level permissions. If this requirement is not met, + then the call is rejected. When false, the alarm evaluates metrics from only the compartment specified + in metricCompartmentId. Default is false. + - "Example: `true`" + type: bool + namespace: + description: + - The source service or application emitting the metric that is evaluated by the alarm. + - "Example: `oci_computeagent`" + - Required for create using I(state=present). + type: str + resource_group: + description: + - Resource group that you want to use as a filter. The alarm retrieves metric data associated with the specified resource group only. Only one + resource group can be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens + (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + type: str + query: + description: + - "The Monitoring Query Language (MQL) expression to evaluate for the alarm. The Alarms feature of + the Monitoring service interprets results for each returned time series as Boolean values, + where zero represents false and a non-zero value represents true. A true value means that the trigger + rule condition has been met. The query must specify a metric, statistic, interval, and trigger + rule (threshold or absence). Supported values for interval: `1m`-`60m` (also `1h`). You can optionally + specify dimensions and grouping functions. Supported grouping functions: `grouping()`, `groupBy()`. + For details about Monitoring Query Language (MQL), see L(Monitoring Query Language (MQL) + Reference,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Reference/mql.htm). + For available dimensions, review the metric definition for the supported service. + See L(Supported Services,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#SupportedServices)." + - "Example of threshold alarm:" + - ----- + - " CpuUtilization[1m]{availabilityDomain=\\"cumS:PHX-AD-1\\"}.groupBy(availabilityDomain).percentile(0.9) > 85" + - ----- + - "Example of absence alarm:" + - ----- + - " CpuUtilization[1m]{availabilityDomain=\\"cumS:PHX-AD-1\\"}.absent()" + - ----- + - Required for create using I(state=present). + type: str + resolution: + description: + - "The time between calculated aggregation windows for the alarm. Supported value: `1m`" + type: str + pending_duration: + description: + - "The period of time that the condition defined in the alarm must persist before the alarm state + changes from \\"OK\\" to \\"FIRING\\". For example, a value of 5 minutes means that the + alarm must persist in breaching the condition for five minutes before the alarm updates its + state to \\"FIRING\\"." + - "The duration is specified as a string in ISO 8601 format (`PT10M` for ten minutes or `PT1H` + for one hour). Minimum: PT1M. Maximum: PT1H. Default: PT1M." + - "Under the default value of PT1M, the first evaluation that breaches the alarm updates the + state to \\"FIRING\\"." + - "The alarm updates its status to \\"OK\\" when the breaching condition has been clear for + the most recent minute." + - "Example: `PT5M`" + type: str + severity: + description: + - "The perceived type of response required when the alarm is in the \\"FIRING\\" state." + - "Example: `CRITICAL`" + - Required for create using I(state=present). + type: str + body: + description: + - The human-readable content of the notification delivered. Oracle recommends providing guidance + to operators for resolving the alarm condition. Consider adding links to standard runbook + practices. Avoid entering confidential information. + - "Example: `High CPU usage alert. Follow runbook instructions for resolution.`" + type: str + destinations: + description: + - "A list of destinations to which the notifications for this alarm will be delivered. + Each destination is represented by an L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) related to the supported + destination service. + For example, a destination using the Notifications service is represented by a topic OCID. + Supported destination services: Notifications Service. Limit: One destination per supported destination service." + - Required for create using I(state=present). + type: list + repeat_notification_duration: + description: + - "The frequency at which notifications are re-submitted, if the alarm keeps firing without + interruption. Format defined by ISO 8601. For example, `PT4H` indicates four hours. + Minimum: PT1M. Maximum: P30D." + - "Default value: null (notifications are not re-submitted)." + - "Example: `PT2H`" + type: str + suppression: + description: + - The configuration details for suppressing an alarm. + type: dict + suboptions: + description: + description: + - Human-readable reason for suppressing alarm notifications. + It does not have to be unique, and it's changeable. + Avoid entering confidential information. + - Oracle recommends including tracking information for the event or associated work, + such as a ticket number. + - "Example: `Planned outage due to change IT-1234.`" + type: str + time_suppress_from: + description: + - The start date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + type: str + required: true + time_suppress_until: + description: + - The end date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T02:02:29.600Z`" + type: str + required: true + is_enabled: + description: + - Whether the alarm is enabled. + - "Example: `true`" + - Required for create using I(state=present). + type: bool + freeform_tags: + description: + - "Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. + Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - "Usage of predefined tag keys. These predefined keys are scoped to namespaces. + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + alarm_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of an alarm. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the Alarm. + - Use I(state=present) to create or update an Alarm. + - Use I(state=absent) to delete an Alarm. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create alarm + oci_monitoring_alarm: + display_name: System Down + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + metric_compartment_id: ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx + namespace: oci_computeagent + query: query_example + severity: CRITICAL + is_enabled: true + +- name: Update alarm using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_monitoring_alarm: + display_name: System Down + +- name: Update alarm + oci_monitoring_alarm: + alarm_id: ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete alarm + oci_monitoring_alarm: + alarm_id: ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete alarm using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_monitoring_alarm: + display_name: System Down + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +alarm: + description: + - Details of the Alarm resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the alarm. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - A user-friendly name for the alarm. It does not have to be unique, and it's changeable. + Avoid entering confidential information. + - This name is sent as the title for notifications related to this alarm. + - "Example: `High CPU Utilization`" + returned: on success + type: string + sample: High CPU Utilization + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the alarm. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + metric_compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the metric + being evaluated by the alarm. + returned: on success + type: string + sample: ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx + metric_compartment_id_in_subtree: + description: + - When true, the alarm evaluates metrics from all compartments and subcompartments. The parameter can + only be set to true when metricCompartmentId is the tenancy OCID (the tenancy is the root compartment). + A true value requires the user to have tenancy-level permissions. If this requirement is not met, + then the call is rejected. When false, the alarm evaluates metrics from only the compartment specified + in metricCompartmentId. Default is false. + - "Example: `true`" + returned: on success + type: bool + sample: true + namespace: + description: + - The source service or application emitting the metric that is evaluated by the alarm. + - "Example: `oci_computeagent`" + returned: on success + type: string + sample: oci_computeagent + resource_group: + description: + - Resource group specified as a filter for metric data retrieved by the alarm. A resource group is a custom string that can be used as a filter. + Only one resource group can be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), + hyphens (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + returned: on success + type: string + sample: frontend-fleet + query: + description: + - "The Monitoring Query Language (MQL) expression to evaluate for the alarm. The Alarms feature of + the Monitoring service interprets results for each returned time series as Boolean values, + where zero represents false and a non-zero value represents true. A true value means that the trigger + rule condition has been met. The query must specify a metric, statistic, interval, and trigger + rule (threshold or absence). Supported values for interval: `1m`-`60m` (also `1h`). You can optionally + specify dimensions and grouping functions. Supported grouping functions: `grouping()`, `groupBy()`. + For details about Monitoring Query Language (MQL), see L(Monitoring Query Language (MQL) + Reference,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Reference/mql.htm). + For available dimensions, review the metric definition for the supported service. + See L(Supported Services,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#SupportedServices)." + - "Example of threshold alarm:" + - ----- + - " CpuUtilization[1m]{availabilityDomain=\\"cumS:PHX-AD-1\\"}.groupBy(availabilityDomain).percentile(0.9) > 85" + - ----- + - "Example of absence alarm:" + - ----- + - " CpuUtilization[1m]{availabilityDomain=\\"cumS:PHX-AD-1\\"}.absent()" + - ----- + returned: on success + type: string + sample: query_example + resolution: + description: + - "The time between calculated aggregation windows for the alarm. Supported value: `1m`" + returned: on success + type: string + sample: resolution_example + pending_duration: + description: + - "The period of time that the condition defined in the alarm must persist before the alarm state + changes from \\"OK\\" to \\"FIRING\\". For example, a value of 5 minutes means that the + alarm must persist in breaching the condition for five minutes before the alarm updates its + state to \\"FIRING\\"." + - "The duration is specified as a string in ISO 8601 format (`PT10M` for ten minutes or `PT1H` + for one hour). Minimum: PT1M. Maximum: PT1H. Default: PT1M." + - "Under the default value of PT1M, the first evaluation that breaches the alarm updates the + state to \\"FIRING\\"." + - "The alarm updates its status to \\"OK\\" when the breaching condition has been clear for + the most recent minute." + - "Example: `PT5M`" + returned: on success + type: string + sample: PT5M + severity: + description: + - "The perceived type of response required when the alarm is in the \\"FIRING\\" state." + - "Example: `CRITICAL`" + returned: on success + type: string + sample: CRITICAL + body: + description: + - The human-readable content of the notification delivered. Oracle recommends providing guidance + to operators for resolving the alarm condition. Consider adding links to standard runbook + practices. Avoid entering confidential information. + - "Example: `High CPU usage alert. Follow runbook instructions for resolution.`" + returned: on success + type: string + sample: High CPU usage alert. Follow runbook instructions for resolution. + destinations: + description: + - "A list of destinations to which the notifications for this alarm will be delivered. + Each destination is represented by an L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) related to the + supported destination service. + For example, a destination using the Notifications service is represented by a topic OCID. + Supported destination services: Notifications Service. Limit: One destination per supported destination service." + returned: on success + type: list + sample: [] + repeat_notification_duration: + description: + - "The frequency at which notifications are re-submitted, if the alarm keeps firing without + interruption. Format defined by ISO 8601. For example, `PT4H` indicates four hours. + Minimum: PT1M. Maximum: P30D." + - "Default value: null (notifications are not re-submitted)." + - "Example: `PT2H`" + returned: on success + type: string + sample: PT2H + suppression: + description: + - The configuration details for suppressing an alarm. + returned: on success + type: complex + contains: + description: + description: + - Human-readable reason for suppressing alarm notifications. + It does not have to be unique, and it's changeable. + Avoid entering confidential information. + - Oracle recommends including tracking information for the event or associated work, + such as a ticket number. + - "Example: `Planned outage due to change IT-1234.`" + returned: on success + type: string + sample: Planned outage due to change IT-1234. + time_suppress_from: + description: + - The start date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + time_suppress_until: + description: + - The end date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T02:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T02:02:29.600Z + is_enabled: + description: + - Whether the alarm is enabled. + - "Example: `true`" + returned: on success + type: bool + sample: true + freeform_tags: + description: + - "Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. + Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - "Usage of predefined tag keys. These predefined keys are scoped to namespaces. + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + lifecycle_state: + description: + - The current lifecycle state of the alarm. + - "Example: `DELETED`" + returned: on success + type: string + sample: DELETED + time_created: + description: + - The date and time the alarm was created. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + time_updated: + description: + - The date and time the alarm was last updated. Format defined by RFC3339. + - "Example: `2019-02-03T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-03T01:02:29.600Z + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "High CPU Utilization", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "metric_compartment_id": "ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx", + "metric_compartment_id_in_subtree": true, + "namespace": "oci_computeagent", + "resource_group": "frontend-fleet", + "query": "query_example", + "resolution": "resolution_example", + "pending_duration": "PT5M", + "severity": "CRITICAL", + "body": "High CPU usage alert. Follow runbook instructions for resolution.", + "destinations": [], + "repeat_notification_duration": "PT2H", + "suppression": { + "description": "Planned outage due to change IT-1234.", + "time_suppress_from": "2019-02-01T01:02:29.600Z", + "time_suppress_until": "2019-02-01T02:02:29.600Z" + }, + "is_enabled": true, + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "lifecycle_state": "DELETED", + "time_created": "2019-02-01T01:02:29.600Z", + "time_updated": "2019-02-03T01:02:29.600Z" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + from oci.monitoring.models import CreateAlarmDetails + from oci.monitoring.models import UpdateAlarmDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class AlarmHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "alarm_id" + + def get_module_resource_id(self): + return self.module.params.get("alarm_id") + + def get_get_fn(self): + return self.client.get_alarm + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_alarm, alarm_id=self.module.params.get("alarm_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_alarms, **kwargs) + + def get_create_model_class(self): + return CreateAlarmDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_alarm, + call_fn_args=(), + call_fn_kwargs=dict(create_alarm_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateAlarmDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_alarm, + call_fn_args=(), + call_fn_kwargs=dict( + alarm_id=self.module.params.get("alarm_id"), + update_alarm_details=update_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_alarm, + call_fn_args=(), + call_fn_kwargs=dict(alarm_id=self.module.params.get("alarm_id"),), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +AlarmHelperCustom = get_custom_class("AlarmHelperCustom") + + +class ResourceHelper(AlarmHelperCustom, AlarmHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + display_name=dict(aliases=["name"], type="str"), + compartment_id=dict(type="str"), + metric_compartment_id=dict(type="str"), + metric_compartment_id_in_subtree=dict(type="bool"), + namespace=dict(type="str"), + resource_group=dict(type="str"), + query=dict(type="str"), + resolution=dict(type="str"), + pending_duration=dict(type="str"), + severity=dict(type="str"), + body=dict(type="str"), + destinations=dict(type="list"), + repeat_notification_duration=dict(type="str"), + suppression=dict( + type="dict", + options=dict( + description=dict(type="str"), + time_suppress_from=dict(type="str", required=True), + time_suppress_until=dict(type="str", required=True), + ), + ), + is_enabled=dict(type="bool"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + alarm_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="alarm", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_alarm_facts.py b/plugins/modules/oci_monitoring_alarm_facts.py new file mode 100644 index 0000000000..8db5c7bc16 --- /dev/null +++ b/plugins/modules/oci_monitoring_alarm_facts.py @@ -0,0 +1,449 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_alarm_facts +short_description: Fetches details about one or multiple Alarm resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Alarm resources in Oracle Cloud Infrastructure + - Lists the alarms for the specified compartment. + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + - This call is subject to a Monitoring limit that applies to the total number of requests across all alarm operations. + Monitoring might throttle this call to reject an otherwise valid request when the total rate of alarm operations exceeds 10 requests, + or transactions, per second (TPS) for a given tenancy. + - If I(alarm_id) is specified, the details of a single Alarm will be returned. +version_added: "2.5" +options: + alarm_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of an alarm. + - Required to get a specific alarm. + type: str + aliases: ["id"] + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the + resources monitored by the metric that you are searching for. Use tenancyId to search in + the root compartment. + - "Example: `ocid1.compartment.oc1..exampleuniqueID`" + - Required to list multiple alarms. + type: str + display_name: + description: + - A filter to return only resources that match the given display name exactly. + Use this filter to list an alarm by name. Alternatively, when you know the alarm OCID, use the GetAlarm operation. + type: str + aliases: ["name"] + lifecycle_state: + description: + - A filter to return only alarms that match the given lifecycle state exactly. When not specified, only alarms in the ACTIVE lifecycle state are + listed. + type: str + choices: + - "ACTIVE" + - "DELETING" + - "DELETED" + sort_by: + description: + - The field to use when sorting returned alarm definitions. Only one sorting level is provided. + - "Example: `severity`" + type: str + choices: + - "displayName" + - "severity" + sort_order: + description: + - The sort order to use when sorting returned alarm definitions. Ascending (ASC) or descending (DESC). + - "Example: `ASC`" + type: str + choices: + - "ASC" + - "DESC" + compartment_id_in_subtree: + description: + - When true, returns resources from all compartments and subcompartments. The parameter can + only be set to true when compartmentId is the tenancy OCID (the tenancy is the root compartment). + A true value requires the user to have tenancy-level permissions. If this requirement is not met, + then the call is rejected. When false, returns resources from only the compartment specified in + compartmentId. Default is false. + type: bool +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List alarms + oci_monitoring_alarm_facts: + compartment_id: ocid1.compartment.oc1..exampleuniqueID + +- name: Get a specific alarm + oci_monitoring_alarm_facts: + alarm_id: ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +alarms: + description: + - List of Alarm resources + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the alarm. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - A user-friendly name for the alarm. It does not have to be unique, and it's changeable. + Avoid entering confidential information. + - This name is sent as the title for notifications related to this alarm. + - "Example: `High CPU Utilization`" + returned: on success + type: string + sample: High CPU Utilization + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the alarm. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + metric_compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the metric + being evaluated by the alarm. + returned: on success + type: string + sample: ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx + metric_compartment_id_in_subtree: + description: + - When true, the alarm evaluates metrics from all compartments and subcompartments. The parameter can + only be set to true when metricCompartmentId is the tenancy OCID (the tenancy is the root compartment). + A true value requires the user to have tenancy-level permissions. If this requirement is not met, + then the call is rejected. When false, the alarm evaluates metrics from only the compartment specified + in metricCompartmentId. Default is false. + - "Example: `true`" + returned: on success + type: bool + sample: true + namespace: + description: + - The source service or application emitting the metric that is evaluated by the alarm. + - "Example: `oci_computeagent`" + returned: on success + type: string + sample: oci_computeagent + resource_group: + description: + - Resource group specified as a filter for metric data retrieved by the alarm. A resource group is a custom string that can be used as a filter. + Only one resource group can be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), + hyphens (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + returned: on success + type: string + sample: frontend-fleet + query: + description: + - "The Monitoring Query Language (MQL) expression to evaluate for the alarm. The Alarms feature of + the Monitoring service interprets results for each returned time series as Boolean values, + where zero represents false and a non-zero value represents true. A true value means that the trigger + rule condition has been met. The query must specify a metric, statistic, interval, and trigger + rule (threshold or absence). Supported values for interval: `1m`-`60m` (also `1h`). You can optionally + specify dimensions and grouping functions. Supported grouping functions: `grouping()`, `groupBy()`. + For details about Monitoring Query Language (MQL), see L(Monitoring Query Language (MQL) + Reference,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Reference/mql.htm). + For available dimensions, review the metric definition for the supported service. + See L(Supported Services,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#SupportedServices)." + - "Example of threshold alarm:" + - ----- + - " CpuUtilization[1m]{availabilityDomain=\\"cumS:PHX-AD-1\\"}.groupBy(availabilityDomain).percentile(0.9) > 85" + - ----- + - "Example of absence alarm:" + - ----- + - " CpuUtilization[1m]{availabilityDomain=\\"cumS:PHX-AD-1\\"}.absent()" + - ----- + returned: on success + type: string + sample: query_example + resolution: + description: + - "The time between calculated aggregation windows for the alarm. Supported value: `1m`" + returned: on success + type: string + sample: resolution_example + pending_duration: + description: + - "The period of time that the condition defined in the alarm must persist before the alarm state + changes from \\"OK\\" to \\"FIRING\\". For example, a value of 5 minutes means that the + alarm must persist in breaching the condition for five minutes before the alarm updates its + state to \\"FIRING\\"." + - "The duration is specified as a string in ISO 8601 format (`PT10M` for ten minutes or `PT1H` + for one hour). Minimum: PT1M. Maximum: PT1H. Default: PT1M." + - "Under the default value of PT1M, the first evaluation that breaches the alarm updates the + state to \\"FIRING\\"." + - "The alarm updates its status to \\"OK\\" when the breaching condition has been clear for + the most recent minute." + - "Example: `PT5M`" + returned: on success + type: string + sample: PT5M + severity: + description: + - "The perceived type of response required when the alarm is in the \\"FIRING\\" state." + - "Example: `CRITICAL`" + returned: on success + type: string + sample: CRITICAL + body: + description: + - The human-readable content of the notification delivered. Oracle recommends providing guidance + to operators for resolving the alarm condition. Consider adding links to standard runbook + practices. Avoid entering confidential information. + - "Example: `High CPU usage alert. Follow runbook instructions for resolution.`" + returned: on success + type: string + sample: High CPU usage alert. Follow runbook instructions for resolution. + destinations: + description: + - "A list of destinations to which the notifications for this alarm will be delivered. + Each destination is represented by an L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) related to the + supported destination service. + For example, a destination using the Notifications service is represented by a topic OCID. + Supported destination services: Notifications Service. Limit: One destination per supported destination service." + returned: on success + type: list + sample: [] + repeat_notification_duration: + description: + - "The frequency at which notifications are re-submitted, if the alarm keeps firing without + interruption. Format defined by ISO 8601. For example, `PT4H` indicates four hours. + Minimum: PT1M. Maximum: P30D." + - "Default value: null (notifications are not re-submitted)." + - "Example: `PT2H`" + returned: on success + type: string + sample: PT2H + suppression: + description: + - The configuration details for suppressing an alarm. + returned: on success + type: complex + contains: + description: + description: + - Human-readable reason for suppressing alarm notifications. + It does not have to be unique, and it's changeable. + Avoid entering confidential information. + - Oracle recommends including tracking information for the event or associated work, + such as a ticket number. + - "Example: `Planned outage due to change IT-1234.`" + returned: on success + type: string + sample: Planned outage due to change IT-1234. + time_suppress_from: + description: + - The start date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + time_suppress_until: + description: + - The end date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T02:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T02:02:29.600Z + is_enabled: + description: + - Whether the alarm is enabled. + - "Example: `true`" + returned: on success + type: bool + sample: true + freeform_tags: + description: + - "Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. + Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - "Usage of predefined tag keys. These predefined keys are scoped to namespaces. + Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + lifecycle_state: + description: + - The current lifecycle state of the alarm. + - "Example: `DELETED`" + returned: on success + type: string + sample: DELETED + time_created: + description: + - The date and time the alarm was created. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + time_updated: + description: + - The date and time the alarm was last updated. Format defined by RFC3339. + - "Example: `2019-02-03T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-03T01:02:29.600Z + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "High CPU Utilization", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "metric_compartment_id": "ocid1.metriccompartment.oc1..xxxxxxEXAMPLExxxxxx", + "metric_compartment_id_in_subtree": true, + "namespace": "oci_computeagent", + "resource_group": "frontend-fleet", + "query": "query_example", + "resolution": "resolution_example", + "pending_duration": "PT5M", + "severity": "CRITICAL", + "body": "High CPU usage alert. Follow runbook instructions for resolution.", + "destinations": [], + "repeat_notification_duration": "PT2H", + "suppression": { + "description": "Planned outage due to change IT-1234.", + "time_suppress_from": "2019-02-01T01:02:29.600Z", + "time_suppress_until": "2019-02-01T02:02:29.600Z" + }, + "is_enabled": true, + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "lifecycle_state": "DELETED", + "time_created": "2019-02-01T01:02:29.600Z", + "time_updated": "2019-02-03T01:02:29.600Z" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class AlarmFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "alarm_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_alarm, alarm_id=self.module.params.get("alarm_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "display_name", + "lifecycle_state", + "sort_by", + "sort_order", + "compartment_id_in_subtree", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_alarms, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +AlarmFactsHelperCustom = get_custom_class("AlarmFactsHelperCustom") + + +class ResourceFactsHelper(AlarmFactsHelperCustom, AlarmFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + alarm_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + display_name=dict(aliases=["name"], type="str"), + lifecycle_state=dict(type="str", choices=["ACTIVE", "DELETING", "DELETED"]), + sort_by=dict(type="str", choices=["displayName", "severity"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + compartment_id_in_subtree=dict(type="bool"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="alarm", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(alarms=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_alarm_history_collection_facts.py b/plugins/modules/oci_monitoring_alarm_history_collection_facts.py new file mode 100644 index 0000000000..548cfad246 --- /dev/null +++ b/plugins/modules/oci_monitoring_alarm_history_collection_facts.py @@ -0,0 +1,220 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_alarm_history_collection_facts +short_description: Fetches details about a AlarmHistoryCollection resource in Oracle Cloud Infrastructure +description: + - Fetches details about a AlarmHistoryCollection resource in Oracle Cloud Infrastructure + - Get the history of the specified alarm. + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + - This call is subject to a Monitoring limit that applies to the total number of requests across all alarm operations. + Monitoring might throttle this call to reject an otherwise valid request when the total rate of alarm operations exceeds 10 requests, + or transactions, per second (TPS) for a given tenancy. +version_added: "2.5" +options: + alarm_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of an alarm. + type: str + aliases: ["id"] + required: true + alarm_historytype: + description: + - The type of history entries to retrieve. State history (STATE_HISTORY) or state transition history (STATE_TRANSITION_HISTORY). + If not specified, entries of both types are retrieved. + - "Example: `STATE_HISTORY`" + type: str + choices: + - "STATE_HISTORY" + - "STATE_TRANSITION_HISTORY" + timestamp_greater_than_or_equal_to: + description: + - A filter to return only alarm history entries with timestamps occurring on or after the specified date and time. Format defined by RFC3339. + - "Example: `2019-01-01T01:00:00.789Z`" + type: str + timestamp_less_than: + description: + - A filter to return only alarm history entries with timestamps occurring before the specified date and time. Format defined by RFC3339. + - "Example: `2019-01-02T01:00:00.789Z`" + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific alarm_history_collection + oci_monitoring_alarm_history_collection_facts: + alarm_id: ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +alarm_history_collection: + description: + - AlarmHistoryCollection resource + returned: on success + type: complex + contains: + alarm_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the alarm for which to retrieve history. + returned: on success + type: string + sample: ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx + is_enabled: + description: + - Whether the alarm is enabled. + - "Example: `true`" + returned: on success + type: bool + sample: true + entries: + description: + - The set of history entries retrieved for the alarm. + returned: on success + type: complex + contains: + summary: + description: + - Description for this alarm history entry. Avoid entering confidential information. + - "Example 1 - alarm state history entry: `The alarm state is FIRING`" + - "Example 2 - alarm state transition history entry: `State transitioned from OK to Firing`" + returned: on success + type: string + sample: summary_example + timestamp: + description: + - Timestamp for this alarm history entry. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + timestamp_triggered: + description: + - "Timestamp for the transition of the alarm state. For example, the time when the alarm transitioned from OK to Firing. + Available for state transition entries only. Note: A three-minute lag for this value accounts for any late-arriving metrics." + - "Example: `2019-02-01T0:59:00.789Z`" + returned: on success + type: string + sample: 2019-02-01T0:59:00.789Z + sample: { + "alarm_id": "ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx", + "is_enabled": true, + "entries": [{ + "summary": "summary_example", + "timestamp": "2019-02-01T01:02:29.600Z", + "timestamp_triggered": "2019-02-01T0:59:00.789Z" + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class AlarmHistoryCollectionFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "alarm_id", + ] + + def get_resource(self): + optional_get_method_params = [ + "alarm_historytype", + "timestamp_greater_than_or_equal_to", + "timestamp_less_than", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_get_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.call_with_backoff( + self.client.get_alarm_history, + alarm_id=self.module.params.get("alarm_id"), + **optional_kwargs + ) + + +AlarmHistoryCollectionFactsHelperCustom = get_custom_class( + "AlarmHistoryCollectionFactsHelperCustom" +) + + +class ResourceFactsHelper( + AlarmHistoryCollectionFactsHelperCustom, AlarmHistoryCollectionFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + alarm_id=dict(aliases=["id"], type="str", required=True), + alarm_historytype=dict( + type="str", choices=["STATE_HISTORY", "STATE_TRANSITION_HISTORY"] + ), + timestamp_greater_than_or_equal_to=dict(type="str"), + timestamp_less_than=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="alarm_history_collection", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(alarm_history_collection=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_alarm_status_facts.py b/plugins/modules/oci_monitoring_alarm_status_facts.py new file mode 100644 index 0000000000..23761ebe1b --- /dev/null +++ b/plugins/modules/oci_monitoring_alarm_status_facts.py @@ -0,0 +1,255 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_alarm_status_facts +short_description: Fetches details about one or multiple AlarmStatus resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple AlarmStatus resources in Oracle Cloud Infrastructure + - List the status of each alarm in the specified compartment. + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + - This call is subject to a Monitoring limit that applies to the total number of requests across all alarm operations. + Monitoring might throttle this call to reject an otherwise valid request when the total rate of alarm operations exceeds 10 requests, + or transactions, per second (TPS) for a given tenancy. +version_added: "2.5" +options: + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the + resources monitored by the metric that you are searching for. Use tenancyId to search in + the root compartment. + - "Example: `ocid1.compartment.oc1..exampleuniqueID`" + type: str + required: true + compartment_id_in_subtree: + description: + - When true, returns resources from all compartments and subcompartments. The parameter can + only be set to true when compartmentId is the tenancy OCID (the tenancy is the root compartment). + A true value requires the user to have tenancy-level permissions. If this requirement is not met, + then the call is rejected. When false, returns resources from only the compartment specified in + compartmentId. Default is false. + type: bool + display_name: + description: + - A filter to return only resources that match the given display name exactly. + Use this filter to list an alarm by name. Alternatively, when you know the alarm OCID, use the GetAlarm operation. + type: str + aliases: ["name"] + sort_by: + description: + - The field to use when sorting returned alarm definitions. Only one sorting level is provided. + - "Example: `severity`" + type: str + choices: + - "displayName" + - "severity" + sort_order: + description: + - The sort order to use when sorting returned alarm definitions. Ascending (ASC) or descending (DESC). + - "Example: `ASC`" + type: str + choices: + - "ASC" + - "DESC" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List alarm_statuses + oci_monitoring_alarm_status_facts: + compartment_id: ocid1.compartment.oc1..exampleuniqueID + +""" + +RETURN = """ +alarm_statuses: + description: + - List of AlarmStatus resources + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the alarm. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + display_name: + description: + - The configured name of the alarm. + - "Example: `High CPU Utilization`" + returned: on success + type: string + sample: High CPU Utilization + severity: + description: + - The configured severity of the alarm. + - "Example: `CRITICAL`" + returned: on success + type: string + sample: CRITICAL + timestamp_triggered: + description: + - Timestamp for the transition of the alarm state. For example, the time when the alarm transitioned from OK to Firing. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + status: + description: + - The status of this alarm. + - "Example: `FIRING`" + returned: on success + type: string + sample: FIRING + suppression: + description: + - The configuration details for suppressing an alarm. + returned: on success + type: complex + contains: + description: + description: + - Human-readable reason for suppressing alarm notifications. + It does not have to be unique, and it's changeable. + Avoid entering confidential information. + - Oracle recommends including tracking information for the event or associated work, + such as a ticket number. + - "Example: `Planned outage due to change IT-1234.`" + returned: on success + type: string + sample: Planned outage due to change IT-1234. + time_suppress_from: + description: + - The start date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + time_suppress_until: + description: + - The end date and time for the suppression to take place, inclusive. Format defined by RFC3339. + - "Example: `2019-02-01T02:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T02:02:29.600Z + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "display_name": "High CPU Utilization", + "severity": "CRITICAL", + "timestamp_triggered": "2019-02-01T01:02:29.600Z", + "status": "FIRING", + "suppression": { + "description": "Planned outage due to change IT-1234.", + "time_suppress_from": "2019-02-01T01:02:29.600Z", + "time_suppress_until": "2019-02-01T02:02:29.600Z" + } + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class AlarmStatusFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: list""" + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def list_resources(self): + optional_list_method_params = [ + "compartment_id_in_subtree", + "display_name", + "sort_by", + "sort_order", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_alarms_status, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +AlarmStatusFactsHelperCustom = get_custom_class("AlarmStatusFactsHelperCustom") + + +class ResourceFactsHelper(AlarmStatusFactsHelperCustom, AlarmStatusFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + compartment_id=dict(type="str", required=True), + compartment_id_in_subtree=dict(type="bool"), + display_name=dict(aliases=["name"], type="str"), + sort_by=dict(type="str", choices=["displayName", "severity"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="alarm_status", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(alarm_statuses=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_metric_actions.py b/plugins/modules/oci_monitoring_metric_actions.py new file mode 100644 index 0000000000..c5ecaf0fbb --- /dev/null +++ b/plugins/modules/oci_monitoring_metric_actions.py @@ -0,0 +1,290 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_metric_actions +short_description: Perform actions on a Metric resource in Oracle Cloud Infrastructure +description: + - Perform actions on a Metric resource in Oracle Cloud Infrastructure + - "For I(action=list), returns metric definitions that match the criteria specified in the request. Compartment OCID required. + For information about metrics, see L(Metrics + Overview,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#MetricsOverview). + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + Transactions Per Second (TPS) per-tenancy limit for this operation: 10." +version_added: "2.5" +options: + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the + resources monitored by the metric that you are searching for. Use tenancyId to search in + the root compartment. + - "Example: `ocid1.compartment.oc1..exampleuniqueID`" + type: str + required: true + name: + description: + - The metric name to use when searching for metric definitions. + - "Example: `CpuUtilization`" + type: str + namespace: + description: + - The source service or application to use when searching for metric definitions. + - "Example: `oci_computeagent`" + type: str + resource_group: + description: + - Resource group that you want to use as a filter. The specified resource group must exist in the definition of the posted metric. Only one resource + group can be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens + (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + type: str + dimension_filters: + description: + - Qualifiers that you want to use when searching for metric definitions. + Available dimensions vary by metric namespace. Each dimension takes the form of a key-value pair. + - "Example: { \\"resourceId\\": \\"<instance_OCID>\\" }" + type: dict + group_by: + description: + - "Group metrics by these fields in the response. For example, to list all metric namespaces available + in a compartment, groupBy the \\"namespace\\" field. Supported fields: namespace, name, resourceGroup." + - "Example - group by namespace: + `[ \\"namespace\\" ]`" + type: list + sort_by: + description: + - The field to use when sorting returned metric definitions. Only one sorting level is provided. + - "Example: `NAMESPACE`" + type: str + choices: + - "NAMESPACE" + - "NAME" + - "RESOURCEGROUP" + sort_order: + description: + - The sort order to use when sorting returned metric definitions. Ascending (ASC) or + descending (DESC). + - "Example: `ASC`" + type: str + choices: + - "ASC" + - "DESC" + compartment_id_in_subtree: + description: + - When true, returns resources from all compartments and subcompartments. The parameter can + only be set to true when compartmentId is the tenancy OCID (the tenancy is the root compartment). + A true value requires the user to have tenancy-level permissions. If this requirement is not met, + then the call is rejected. When false, returns resources from only the compartment specified in + compartmentId. Default is false. + type: bool + action: + description: + - The action to perform on the Metric. + type: str + required: true + choices: + - "list" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Perform action list on metric + oci_monitoring_metric_actions: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + group_by: + - namespace + action: list + +- name: Perform action list on metric + oci_monitoring_metric_actions: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + group_by: + - resourceGroup + namespace: my_namespace + action: list + +- name: Perform action list on metric + oci_monitoring_metric_actions: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + group_by: + - name + namespace: my_namespace + resource_group: my_resourcegroup + action: list + +""" + +RETURN = """ +metric: + description: + - Details of the Metric resource acted upon by the current operation + returned: on success + type: complex + contains: + name: + description: + - The name of the metric. + - "Example: `CpuUtilization`" + returned: on success + type: string + sample: CpuUtilization + namespace: + description: + - The source service or application emitting the metric. + - "Example: `oci_computeagent`" + returned: on success + type: string + sample: oci_computeagent + resource_group: + description: + - Resource group provided with the posted metric. A resource group is a custom string that can be used as a filter. Only one resource group can + be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), + hyphens (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + returned: on success + type: string + sample: frontend-fleet + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing + the resources monitored by the metric. + returned: on success + type: string + sample: ocid1.compartment.oc1..exampleuniqueID + dimensions: + description: + - Qualifiers provided in a metric definition. Available dimensions vary by metric namespace. + Each dimension takes the form of a key-value pair. + - "Example: `\\"resourceId\\": \\"ocid1.instance.region1.phx.exampleuniqueID\\"`" + returned: on success + type: dict + sample: {} + sample: { + "name": "CpuUtilization", + "namespace": "oci_computeagent", + "resource_group": "frontend-fleet", + "compartment_id": "ocid1.compartment.oc1..exampleuniqueID", + "dimensions": {} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIActionsHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + from oci.monitoring.models import ListMetricsDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class MetricActionsHelperGen(OCIActionsHelperBase): + """ + Supported actions: + list + """ + + def list(self): + action_details = oci_common_utils.convert_input_data_to_model_class( + self.module.params, ListMetricsDetails + ) + return oci_wait_utils.call_and_wait( + call_fn=self.client.list_metrics, + call_fn_args=(), + call_fn_kwargs=dict( + compartment_id=self.module.params.get("compartment_id"), + list_metrics_details=action_details, + compartment_id_in_subtree=self.module.params.get( + "compartment_id_in_subtree" + ), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_action_desired_states( + self.module.params.get("action") + ), + ) + + +MetricActionsHelperCustom = get_custom_class("MetricActionsHelperCustom") + + +class ResourceHelper(MetricActionsHelperCustom, MetricActionsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + compartment_id=dict(type="str", required=True), + name=dict(type="str"), + namespace=dict(type="str"), + resource_group=dict(type="str"), + dimension_filters=dict(type="dict"), + group_by=dict(type="list"), + sort_by=dict(type="str", choices=["NAMESPACE", "NAME", "RESOURCEGROUP"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + compartment_id_in_subtree=dict(type="bool"), + action=dict(type="str", required=True, choices=["list"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="metric", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = resource_helper.perform_action(module.params.get("action")) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_metric_data.py b/plugins/modules/oci_monitoring_metric_data.py new file mode 100644 index 0000000000..c5526d81c8 --- /dev/null +++ b/plugins/modules/oci_monitoring_metric_data.py @@ -0,0 +1,408 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_metric_data +short_description: Manage a MetricData resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create a MetricData resource in Oracle Cloud Infrastructure + - For I(state=present), publishes raw metric data points to the Monitoring service. + For more information about publishing metrics, see L(Publishing Custom + Metrics,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Tasks/publishingcustommetrics.htm). + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + - Per-call limits information follows. + - "* Dimensions per metric group*. Maximum: 20. Minimum: 1. + * Unique metric streams*. Maximum: 50. + * Transactions Per Second (TPS) per-tenancy limit for this operation: 50." + - "*A metric group is the combination of a given metric, metric namespace, and tenancy for the purpose of determining limits. + A dimension is a qualifier provided in a metric definition. + A metric stream is an individual set of aggregated data for a metric, typically specific to a resource. + For more information about metric-related concepts, see L(Monitoring + Concepts,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#concepts)." + - "The endpoints for this operation differ from other Monitoring operations. Replace the string `telemetry` with `telemetry-ingestion` in the endpoint, as + in the following example:" + - https://telemetry-ingestion.eu-frankfurt-1.oraclecloud.com + - "This resource has the following action operations in the M(oci_metric_data_actions) module: summarize_metrics_data." +version_added: "2.9" +author: Oracle (@oracle) +options: + metric_data: + description: + - A metric object containing raw metric data points to be posted to the Monitoring service. + type: list + required: true + suboptions: + namespace: + description: + - The source service or application emitting the metric. + - "A valid namespace value starts with an alphabetical character and includes only alphanumeric characters and underscores. The \\"oci_\\" + prefix is reserved. + Avoid entering confidential information." + - "Example: `my_namespace`" + type: str + required: true + resource_group: + description: + - Resource group to assign to the metric. A resource group is a custom string that can be used as a filter. Only one resource group can be + applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), + hyphens (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + type: str + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment to use for metrics. + type: str + required: true + name: + description: + - The name of the metric. + - A valid name value starts with an alphabetical character and includes only alphanumeric characters, dots, underscores, hyphens, and dollar + signs. The `oci_` prefix is reserved. + Avoid entering confidential information. + - "Example: `my_app.success_rate`" + type: str + required: true + dimensions: + description: + - Qualifiers provided in a metric definition. Available dimensions vary by metric namespace. + Each dimension takes the form of a key-value pair. + A valid dimension key includes only printable ASCII, excluding periods (.) and spaces. The character limit for a dimension key is 256. + A valid dimension value includes only Unicode characters. The character limit for a dimension value is 256. + Empty strings are not allowed for keys or values. Avoid entering confidential information. + - "Example: `\\"resourceId\\": \\"ocid1.instance.region1.phx.exampleuniqueID\\"`" + type: dict + required: true + metadata: + description: + - Properties describing metrics. These are not part of the unique fields identifying the metric. + Each metadata item takes the form of a key-value pair. The character limit for a metadata key is 256. The character limit for a metadata + value is 256. + - "Example: `\\"unit\\": \\"bytes\\"`" + type: dict + datapoints: + description: + - A list of metric values with timestamps. At least one data point is required per call. + type: list + required: true + suboptions: + timestamp: + description: + - Timestamp for this metric value. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + type: str + required: true + value: + description: + - Numeric value of the metric. + - "Example: `10.23`" + type: float + required: true + count: + description: + - The number of occurrences of the associated value in the set of data. + - Default is 1. Value must be greater than zero. + type: int + batch_atomicity: + description: + - "Batch atomicity behavior. Requires either partial or full pass of input validation for + metric objects in PostMetricData requests. The default value of NON_ATOMIC requires a + partial pass: at least one metric object in the request must pass input validation, and + any objects that failed validation are identified in the returned summary, along with + their error messages. A value of ATOMIC requires a full pass: all metric objects in + the request must pass input validation." + - "Example: `NON_ATOMIC`" + type: str + choices: + - "ATOMIC" + - "NON_ATOMIC" + state: + description: + - The state of the MetricData. + - Use I(state=present) to create a MetricData. + type: str + required: false + default: 'present' + choices: ["present"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] +""" + +EXAMPLES = """ +- name: Create metric_data + oci_monitoring_metric_data: + metric_data: + - namespace: my_namespace + compartment_id: ocid1.compartment.oc1..exampleuniqueID + name: my_app.success_rate + datapoints: + - timestamp: 2019-02-01T01:02:29.600Z + value: 10.23 + +""" + +RETURN = """ +metric_data: + description: + - Details of the MetricData resource acted upon by the current operation + returned: on success + type: complex + contains: + failed_metrics_count: + description: + - The number of metric objects that failed input validation. + returned: on success + type: int + sample: 56 + failed_metrics: + description: + - A list of records identifying metric objects that failed input validation + and the reasons for the failures. + returned: on success + type: complex + contains: + message: + description: + - An error message indicating the reason that the indicated metric object failed input validation. + returned: on success + type: string + sample: message_example + metric_data: + description: + - Identifier of a metric object that failed input validation. + returned: on success + type: complex + contains: + namespace: + description: + - The source service or application emitting the metric. + - "A valid namespace value starts with an alphabetical character and includes only alphanumeric characters and underscores. The + \\"oci_\\" prefix is reserved. + Avoid entering confidential information." + - "Example: `my_namespace`" + returned: on success + type: string + sample: my_namespace + resource_group: + description: + - Resource group to assign to the metric. A resource group is a custom string that can be used as a filter. Only one resource + group can be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), + underscores (_), hyphens (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + returned: on success + type: string + sample: frontend-fleet + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment to use for metrics. + returned: on success + type: string + sample: ocid1.compartment.oc1..exampleuniqueID + name: + description: + - The name of the metric. + - A valid name value starts with an alphabetical character and includes only alphanumeric characters, dots, underscores, + hyphens, and dollar signs. The `oci_` prefix is reserved. + Avoid entering confidential information. + - "Example: `my_app.success_rate`" + returned: on success + type: string + sample: my_app.success_rate + dimensions: + description: + - Qualifiers provided in a metric definition. Available dimensions vary by metric namespace. + Each dimension takes the form of a key-value pair. + A valid dimension key includes only printable ASCII, excluding periods (.) and spaces. The character limit for a dimension key + is 256. + A valid dimension value includes only Unicode characters. The character limit for a dimension value is 256. + Empty strings are not allowed for keys or values. Avoid entering confidential information. + - "Example: `\\"resourceId\\": \\"ocid1.instance.region1.phx.exampleuniqueID\\"`" + returned: on success + type: dict + sample: {} + metadata: + description: + - Properties describing metrics. These are not part of the unique fields identifying the metric. + Each metadata item takes the form of a key-value pair. The character limit for a metadata key is 256. The character limit for + a metadata value is 256. + - "Example: `\\"unit\\": \\"bytes\\"`" + returned: on success + type: dict + sample: {} + datapoints: + description: + - A list of metric values with timestamps. At least one data point is required per call. + returned: on success + type: complex + contains: + timestamp: + description: + - Timestamp for this metric value. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + value: + description: + - Numeric value of the metric. + - "Example: `10.23`" + returned: on success + type: float + sample: 10.23 + count: + description: + - The number of occurrences of the associated value in the set of data. + - Default is 1. Value must be greater than zero. + returned: on success + type: int + sample: 56 + sample: { + "failed_metrics_count": 56, + "failed_metrics": [{ + "message": "message_example", + "metric_data": { + "namespace": "my_namespace", + "resource_group": "frontend-fleet", + "compartment_id": "ocid1.compartment.oc1..exampleuniqueID", + "name": "my_app.success_rate", + "dimensions": {}, + "metadata": {}, + "datapoints": [{ + "timestamp": "2019-02-01T01:02:29.600Z", + "value": 10.23, + "count": 56 + }] + } + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + from oci.monitoring.models import PostMetricDataDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class MetricDataHelperGen(OCIResourceHelperBase): + """Supported operations: create""" + + def get_module_resource_id(self): + return None + + # There is no idempotency for this module (no get or list ops) + def get_matching_resource(self): + return None + + def get_create_model_class(self): + return PostMetricDataDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.post_metric_data, + call_fn_args=(), + call_fn_kwargs=dict(post_metric_data_details=create_details,), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + +MetricDataHelperCustom = get_custom_class("MetricDataHelperCustom") + + +class ResourceHelper(MetricDataHelperCustom, MetricDataHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=False + ) + module_args.update( + dict( + metric_data=dict( + type="list", + elements="dict", + required=True, + options=dict( + namespace=dict(type="str", required=True), + resource_group=dict(type="str"), + compartment_id=dict(type="str", required=True), + name=dict(type="str", required=True), + dimensions=dict(type="dict", required=True), + metadata=dict(type="dict"), + datapoints=dict( + type="list", + elements="dict", + required=True, + options=dict( + timestamp=dict(type="str", required=True), + value=dict(type="float", required=True), + count=dict(type="int"), + ), + ), + ), + ), + batch_atomicity=dict(type="str", choices=["ATOMIC", "NON_ATOMIC"]), + state=dict(type="str", default="present", choices=["present"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="metric_data", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = dict(changed=False) + + if resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_metric_data_actions.py b/plugins/modules/oci_monitoring_metric_data_actions.py new file mode 100644 index 0000000000..e74d36619b --- /dev/null +++ b/plugins/modules/oci_monitoring_metric_data_actions.py @@ -0,0 +1,322 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_metric_data_actions +short_description: Perform actions on a MetricData resource in Oracle Cloud Infrastructure +description: + - Perform actions on a MetricData resource in Oracle Cloud Infrastructure + - "For I(action=summarize_metrics_data), returns aggregated data that match the criteria specified in the request. Compartment OCID required. + For information on metric queries, see L(Building Metric Queries,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Tasks/buildingqueries.htm). + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + Transactions Per Second (TPS) per-tenancy limit for this operation: 10." +version_added: "2.5" +options: + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the + resources monitored by the metric that you are searching for. Use tenancyId to search in + the root compartment. + - "Example: `ocid1.compartment.oc1..exampleuniqueID`" + type: str + required: true + namespace: + description: + - The source service or application to use when searching for metric data points to aggregate. + - "Example: `oci_computeagent`" + type: str + required: true + resource_group: + description: + - Resource group that you want to use as a filter. The specified resource group must exist in the definition of the posted metric. Only one resource + group can be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), hyphens + (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + type: str + query: + description: + - "The Monitoring Query Language (MQL) expression to use when searching for metric data points to + aggregate. The query must specify a metric, statistic, and interval. Supported values for + interval: `1m`-`60m` (also `1h`). You can optionally specify dimensions and grouping functions. + Supported grouping functions: `grouping()`, `groupBy()`." + - Construct your query to avoid exceeding limits on returned data. See L(MetricData + Reference,https://docs.cloud.oracle.com/#/en/monitoring/20180401/MetricData). + - For details about Monitoring Query Language (MQL), see + L(Monitoring Query Language (MQL) Reference,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Reference/mql.htm). + For available dimensions, review the metric definition for the supported service. + See L(Supported Services,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#SupportedServices). + - "Example: `CpuUtilization[1m].sum()`" + type: str + required: true + start_time: + description: + - "The beginning of the time range to use when searching for metric data points. + Format is defined by RFC3339. The response includes metric data points for the startTime. + Default value: the timestamp 3 hours before the call was sent." + - "Example: `2019-02-01T01:02:29.600Z`" + type: str + end_time: + description: + - "The end of the time range to use when searching for metric data points. + Format is defined by RFC3339. The response excludes metric data points for the endTime. + Default value: the timestamp representing when the call was sent." + - "Example: `2019-02-01T02:02:29.600Z`" + type: str + resolution: + description: + - "The time between calculated aggregation windows. Use with the query interval to vary the + frequency at which aggregated data points are returned. For example, use a query interval of + 5 minutes with a resolution of 1 minute to retrieve five-minute aggregations at a one-minute + frequency. The resolution must be equal or less than the interval in the query. The default + resolution is 1m (one minute). Supported values: `1m`-`60m` (also `1h`)." + - "Example: `5m`" + type: str + compartment_id_in_subtree: + description: + - When true, returns resources from all compartments and subcompartments. The parameter can + only be set to true when compartmentId is the tenancy OCID (the tenancy is the root compartment). + A true value requires the user to have tenancy-level permissions. If this requirement is not met, + then the call is rejected. When false, returns resources from only the compartment specified in + compartmentId. Default is false. + type: bool + action: + description: + - The action to perform on the MetricData. + type: str + required: true + choices: + - "summarize_metrics_data" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Perform action summarize_metrics_data on metric_data + oci_monitoring_metric_data_actions: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + namespace: oci_computeagent + query: CpuUtilization[1m]{resourceId:}.max() + start_time: 2019-03-10T22:19:26.789Z + end_time: 2019-03-10T22:28:26.789Z + action: summarize_metrics_data + +""" + +RETURN = """ +metric_data: + description: + - Details of the MetricData resource acted upon by the current operation + returned: on success + type: complex + contains: + namespace: + description: + - The reference provided in a metric definition to indicate the source service or + application that emitted the metric. + - "Example: `oci_computeagent`" + returned: on success + type: string + sample: oci_computeagent + resource_group: + description: + - Resource group provided with the posted metric. A resource group is a custom string that can be used as a filter. Only one resource group can + be applied per metric. + A valid resourceGroup value starts with an alphabetical character and includes only alphanumeric characters, periods (.), underscores (_), + hyphens (-), and dollar signs ($). + Avoid entering confidential information. + - "Example: `frontend-fleet`" + returned: on success + type: string + sample: frontend-fleet + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the + resources from which the aggregated data was returned. + returned: on success + type: string + sample: ocid1.compartment.oc1..exampleuniqueID + name: + description: + - The name of the metric. + - "Example: `CpuUtilization`" + returned: on success + type: string + sample: CpuUtilization + dimensions: + description: + - Qualifiers provided in the definition of the returned metric. + Available dimensions vary by metric namespace. Each dimension takes the form of a key-value pair. + - "Example: `\\"resourceId\\": \\"ocid1.instance.region1.phx.exampleuniqueID\\"`" + returned: on success + type: dict + sample: {} + metadata: + description: + - The references provided in a metric definition to indicate extra information about the metric. + - "Example: `\\"unit\\": \\"bytes\\"`" + returned: on success + type: dict + sample: {} + resolution: + description: + - "The time between calculated aggregation windows. Use with the query interval to vary the + frequency at which aggregated data points are returned. For example, use a query interval of + 5 minutes with a resolution of 1 minute to retrieve five-minute aggregations at a one-minute + frequency. The resolution must be equal or less than the interval in the query. The default + resolution is 1m (one minute). Supported values: `1m`-`60m` (also `1h`)." + - "Example: `5m`" + returned: on success + type: string + sample: 5m + aggregated_datapoints: + description: + - The list of timestamp-value pairs returned for the specified request. Metric values are rolled up to the start time specified in the request. + For important limits information related to data points, see MetricData Reference at the top of this page. + returned: on success + type: complex + contains: + timestamp: + description: + - The date and time associated with the value of this data point. Format defined by RFC3339. + - "Example: `2019-02-01T01:02:29.600Z`" + returned: on success + type: string + sample: 2019-02-01T01:02:29.600Z + value: + description: + - Numeric value of the metric. + - "Example: `10.4`" + returned: on success + type: float + sample: 10.4 + sample: { + "namespace": "oci_computeagent", + "resource_group": "frontend-fleet", + "compartment_id": "ocid1.compartment.oc1..exampleuniqueID", + "name": "CpuUtilization", + "dimensions": {}, + "metadata": {}, + "resolution": "5m", + "aggregated_datapoints": [{ + "timestamp": "2019-02-01T01:02:29.600Z", + "value": 10.4 + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIActionsHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + from oci.monitoring.models import SummarizeMetricsDataDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class MetricDataActionsHelperGen(OCIActionsHelperBase): + """ + Supported actions: + summarize_metrics_data + """ + + def summarize_metrics_data(self): + action_details = oci_common_utils.convert_input_data_to_model_class( + self.module.params, SummarizeMetricsDataDetails + ) + return oci_wait_utils.call_and_wait( + call_fn=self.client.summarize_metrics_data, + call_fn_args=(), + call_fn_kwargs=dict( + compartment_id=self.module.params.get("compartment_id"), + summarize_metrics_data_details=action_details, + compartment_id_in_subtree=self.module.params.get( + "compartment_id_in_subtree" + ), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_action_desired_states( + self.module.params.get("action") + ), + ) + + +MetricDataActionsHelperCustom = get_custom_class("MetricDataActionsHelperCustom") + + +class ResourceHelper(MetricDataActionsHelperCustom, MetricDataActionsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + compartment_id=dict(type="str", required=True), + namespace=dict(type="str", required=True), + resource_group=dict(type="str"), + query=dict(type="str", required=True), + start_time=dict(type="str"), + end_time=dict(type="str"), + resolution=dict(type="str"), + compartment_id_in_subtree=dict(type="bool"), + action=dict(type="str", required=True, choices=["summarize_metrics_data"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="metric_data", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = resource_helper.perform_action(module.params.get("action")) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_monitoring_suppression_actions.py b/plugins/modules/oci_monitoring_suppression_actions.py new file mode 100644 index 0000000000..e919858a42 --- /dev/null +++ b/plugins/modules/oci_monitoring_suppression_actions.py @@ -0,0 +1,154 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_monitoring_suppression_actions +short_description: Perform actions on a Suppression resource in Oracle Cloud Infrastructure +description: + - Perform actions on a Suppression resource in Oracle Cloud Infrastructure + - For I(action=remove_alarm), removes any existing suppression for the specified alarm. + For important limits information, see L(Limits on + Monitoring,https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). + This call is subject to a Monitoring limit that applies to the total number of requests across all alarm operations. + Monitoring might throttle this call to reject an otherwise valid request when the total rate of alarm operations exceeds 10 requests, + or transactions, per second (TPS) for a given tenancy. +version_added: "2.5" +options: + alarm_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of an alarm. + type: str + aliases: ["id"] + required: true + action: + description: + - The action to perform on the Suppression. + type: str + required: true + choices: + - "remove_alarm" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Perform action remove_alarm on suppression + oci_monitoring_suppression_actions: + alarm_id: ocid1.alarm.oc1..xxxxxxEXAMPLExxxxxx + action: remove_alarm + +""" + +RETURN = """ +suppression: + description: + - Details of the Suppression resource acted upon by the current operation + returned: on success + type: complex + contains: TODO - No response model found or could be returning binary data. + sample: TODO - No response model found or could be returning binary data. +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIActionsHelperBase, + get_custom_class, +) + +try: + from oci.monitoring import MonitoringClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SuppressionActionsHelperGen(OCIActionsHelperBase): + """ + Supported actions: + remove_alarm + """ + + @staticmethod + def get_module_resource_id_param(): + return "alarm_id" + + def get_module_resource_id(self): + return self.module.params.get("alarm_id") + + def remove_alarm(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.remove_alarm_suppression, + call_fn_args=(), + call_fn_kwargs=dict(alarm_id=self.module.params.get("alarm_id"),), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_action_desired_states( + self.module.params.get("action") + ), + ) + + +SuppressionActionsHelperCustom = get_custom_class("SuppressionActionsHelperCustom") + + +class ResourceHelper(SuppressionActionsHelperCustom, SuppressionActionsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + alarm_id=dict(aliases=["id"], type="str", required=True), + action=dict(type="str", required=True, choices=["remove_alarm"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="suppression", + service_client_class=MonitoringClient, + namespace="monitoring", + ) + + result = resource_helper.perform_action(module.params.get("action")) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_network_cpe.py b/plugins/modules/oci_network_cpe.py index 5d8742a7da..d3652c1ff3 100644 --- a/plugins/modules/oci_network_cpe.py +++ b/plugins/modules/oci_network_cpe.py @@ -35,7 +35,8 @@ L(Configuring Your On-Premises Router for an IPSec VPN,https://docs.cloud.oracle.com/Content/Network/Tasks/configuringCPE.htm). - "You may optionally specify a *display name* for the CPE, otherwise a default is provided. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -69,6 +70,19 @@ - "Example: `143.19.23.16`" - Required for create using I(state=present). type: str + cpe_device_shape_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the CPE device type. You can provide + a value if you want to later generate CPE device configuration content for IPSec connections + that use this CPE. You can also call L(UpdateCpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/UpdateCpe) later to + provide a value. For a list of possible values, see + L(ListCpeDeviceShapes,https://docs.cloud.oracle.com/#/en/iaas/20160918/CpeDeviceShapeSummary/ListCpeDeviceShapes). + - "For more information about generating CPE device configuration content, see:" + - " * L(GetCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/GetCpeDeviceConfigContent) + * L(GetIpsecCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/GetIpsecCpeDeviceConfigContent) + * L(GetTunnelCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfigContent) + * L(GetTunnelCpeDeviceConfig,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfig)" + type: str cpe_id: description: - The OCID of the CPE. @@ -85,10 +99,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -105,6 +115,7 @@ defined_tags: {'Operations': {'CostCenter': 'US'}} display_name: MyCpe freeform_tags: {'Department': 'Finance'} + cpe_device_shape_id: ocid1.cpedeviceshape.oc1..xxxxxxEXAMPLExxxxxx - name: Update cpe oci_network_cpe: @@ -174,6 +185,23 @@ returned: on success type: string sample: ip_address_example + cpe_device_shape_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the CPE's device type. + The Networking service maintains a general list of CPE device types (for example, + Cisco ASA). For each type, Oracle provides CPE configuration content that can help + a network engineer configure the CPE. The OCID uniquely identifies the type of + device. To get the OCIDs for the device types on the list, see + L(ListCpeDeviceShapes,https://docs.cloud.oracle.com/#/en/iaas/20160918/CpeDeviceShapeSummary/ListCpeDeviceShapes). + - "For information about how to generate CPE configuration content for a + CPE device type, see:" + - " * L(GetCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/GetCpeDeviceConfigContent) + * L(GetIpsecCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/GetIpsecCpeDeviceConfigContent) + * L(GetTunnelCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfigContent) + * L(GetTunnelCpeDeviceConfig,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfig)" + returned: on success + type: string + sample: ocid1.cpedeviceshape.oc1..xxxxxxEXAMPLExxxxxx time_created: description: - The date and time the CPE was created, in the format defined by RFC3339. @@ -188,6 +216,7 @@ "freeform_tags": {'Department': 'Finance'}, "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", "ip_address": "ip_address_example", + "cpe_device_shape_id": "ocid1.cpedeviceshape.oc1..xxxxxxEXAMPLExxxxxx", "time_created": "2016-08-25T21:10:29.600Z" } """ @@ -229,29 +258,23 @@ def get_resource(self): self.client.get_cpe, cpe_id=self.module.params.get("cpe_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_cpes, **kwargs) def get_create_model_class(self): @@ -320,6 +343,7 @@ def main(): display_name=dict(aliases=["name"], type="str"), freeform_tags=dict(type="dict"), ip_address=dict(type="str"), + cpe_device_shape_id=dict(type="str"), cpe_id=dict(aliases=["id"], type="str"), state=dict(type="str", default="present", choices=["present", "absent"]), ) diff --git a/plugins/modules/oci_network_cpe_config_content_facts.py b/plugins/modules/oci_network_cpe_config_content_facts.py new file mode 100644 index 0000000000..90509243ff --- /dev/null +++ b/plugins/modules/oci_network_cpe_config_content_facts.py @@ -0,0 +1,139 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_network_cpe_config_content_facts +short_description: Fetches details about a CpeConfigContent resource in Oracle Cloud Infrastructure +description: + - Fetches details about a CpeConfigContent resource in Oracle Cloud Infrastructure + - Renders a set of CPE configuration content that can help a network engineer configure the actual + CPE device (for example, a hardware router) represented by the specified L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) + object. + - The rendered content is specific to the type of CPE device (for example, Cisco ASA). Therefore the + L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) must have the CPE's device type specified by the `cpeDeviceShapeId` + attribute. The content optionally includes answers that the customer provides (see + L(UpdateTunnelCpeDeviceConfig,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/UpdateTunnelCpeDeviceConfig)), + merged with a template of other information specific to the CPE device type. + - "The operation returns configuration information for *all* of the + L(IPSecConnection,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/) objects that use the specified CPE. + Here are similar operations:" + - " * L(GetIpsecCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/GetIpsecCpeDeviceConfigContent) + returns CPE configuration content for all tunnels in a single IPSec connection. + * L(GetTunnelCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfigContent) + returns CPE configuration content for a specific tunnel within an IPSec connection." +version_added: "2.5" +options: + cpe_id: + description: + - The OCID of the CPE. + type: str + aliases: ["id"] + required: true +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific cpe_config_content + oci_network_cpe_config_content_facts: + cpe_id: ocid1.cpe.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +cpe_config_content: + description: + - CpeConfigContent resource + returned: on success + type: str + sample: "sample" +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import VirtualNetworkClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class CpeConfigContentFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "cpe_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_cpe_device_config_content, + cpe_id=self.module.params.get("cpe_id"), + ) + + +CpeConfigContentFactsHelperCustom = get_custom_class( + "CpeConfigContentFactsHelperCustom" +) + + +class ResourceFactsHelper( + CpeConfigContentFactsHelperCustom, CpeConfigContentFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update(dict(cpe_id=dict(aliases=["id"], type="str", required=True),)) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="cpe_config_content", + service_client_class=VirtualNetworkClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(cpe_config_content=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_network_cpe_device_shape_facts.py b/plugins/modules/oci_network_cpe_device_shape_facts.py new file mode 100644 index 0000000000..b096e919b9 --- /dev/null +++ b/plugins/modules/oci_network_cpe_device_shape_facts.py @@ -0,0 +1,160 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_network_cpe_device_shape_facts +short_description: Fetches details about one or multiple CpeDeviceShape resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple CpeDeviceShape resources in Oracle Cloud Infrastructure + - "Lists the CPE device types that the Networking service provides CPE configuration + content for (example: Cisco ASA). The content helps a network engineer configure + the actual CPE device represented by a L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) object." + - If you want to generate CPE configuration content for one of the returned CPE device types, + ensure that the L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) object's `cpeDeviceShapeId` attribute is set + to the CPE device type's OCID (returned by this operation). + - "For information about generating CPE configuration content, see these operations:" + - " * L(GetCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/GetCpeDeviceConfigContent) + * L(GetIpsecCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/GetIpsecCpeDeviceConfigContent) + * L(GetTunnelCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfigContent)" +version_added: "2.5" +options: {} +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List cpe_device_shapes + oci_network_cpe_device_shape_facts: + +""" + +RETURN = """ +cpe_device_shapes: + description: + - List of CpeDeviceShape resources + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the CPE device shape. + This value uniquely identifies the type of CPE device. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + cpe_device_info: + description: + - Basic information about this particular CPE device type. + returned: on success + type: complex + contains: + vendor: + description: + - The vendor that makes the CPE device. + returned: on success + type: string + sample: vendor_example + platform_software_version: + description: + - The platform or software version of the CPE device. + returned: on success + type: string + sample: platform_software_version_example + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "cpe_device_info": { + "vendor": "vendor_example", + "platform_software_version": "platform_software_version_example" + } + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import VirtualNetworkClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class CpeDeviceShapeFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: list""" + + def get_required_params_for_list(self): + return [] + + def list_resources(self): + optional_list_method_params = [] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_cpe_device_shapes, **optional_kwargs + ) + + +CpeDeviceShapeFactsHelperCustom = get_custom_class("CpeDeviceShapeFactsHelperCustom") + + +class ResourceFactsHelper( + CpeDeviceShapeFactsHelperCustom, CpeDeviceShapeFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update(dict()) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="cpe_device_shape", + service_client_class=VirtualNetworkClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(cpe_device_shapes=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_network_cpe_facts.py b/plugins/modules/oci_network_cpe_facts.py index 9c670a756b..a59d852f7e 100644 --- a/plugins/modules/oci_network_cpe_facts.py +++ b/plugins/modules/oci_network_cpe_facts.py @@ -38,10 +38,7 @@ - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. - Required to list multiple cpes. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ @@ -105,6 +102,23 @@ returned: on success type: string sample: ip_address_example + cpe_device_shape_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the CPE's device type. + The Networking service maintains a general list of CPE device types (for example, + Cisco ASA). For each type, Oracle provides CPE configuration content that can help + a network engineer configure the CPE. The OCID uniquely identifies the type of + device. To get the OCIDs for the device types on the list, see + L(ListCpeDeviceShapes,https://docs.cloud.oracle.com/#/en/iaas/20160918/CpeDeviceShapeSummary/ListCpeDeviceShapes). + - "For information about how to generate CPE configuration content for a + CPE device type, see:" + - " * L(GetCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/GetCpeDeviceConfigContent) + * L(GetIpsecCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/GetIpsecCpeDeviceConfigContent) + * L(GetTunnelCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfigContent) + * L(GetTunnelCpeDeviceConfig,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfig)" + returned: on success + type: string + sample: ocid1.cpedeviceshape.oc1..xxxxxxEXAMPLExxxxxx time_created: description: - The date and time the CPE was created, in the format defined by RFC3339. @@ -119,6 +133,7 @@ "freeform_tags": {'Department': 'Finance'}, "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", "ip_address": "ip_address_example", + "cpe_device_shape_id": "ocid1.cpedeviceshape.oc1..xxxxxxEXAMPLExxxxxx", "time_created": "2016-08-25T21:10:29.600Z" }] """ diff --git a/plugins/modules/oci_network_cross_connect.py b/plugins/modules/oci_network_cross_connect.py index 9ad4495387..d2d3d25a72 100644 --- a/plugins/modules/oci_network_cross_connect.py +++ b/plugins/modules/oci_network_cross_connect.py @@ -39,7 +39,8 @@ L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). - "You may optionally specify a *display name* for the cross-connect. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -128,10 +129,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -312,32 +309,36 @@ def get_resource(self): cross_connect_id=self.module.params.get("cross_connect_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "cross_connect_group_id", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["cross_connect_group_id", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_cross_connects, **kwargs ) diff --git a/plugins/modules/oci_network_cross_connect_facts.py b/plugins/modules/oci_network_cross_connect_facts.py index f72722cbf0..e4e8e23ace 100644 --- a/plugins/modules/oci_network_cross_connect_facts.py +++ b/plugins/modules/oci_network_cross_connect_facts.py @@ -80,10 +80,7 @@ - "INACTIVE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_cross_connect_group.py b/plugins/modules/oci_network_cross_connect_group.py index d90b05b3eb..a5d69fb2cf 100644 --- a/plugins/modules/oci_network_cross_connect_group.py +++ b/plugins/modules/oci_network_cross_connect_group.py @@ -36,7 +36,8 @@ L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). - "You may optionally specify a *display name* for the cross-connect group. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -86,10 +87,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -238,31 +235,36 @@ def get_resource(self): cross_connect_group_id=self.module.params.get("cross_connect_group_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_cross_connect_groups, **kwargs ) diff --git a/plugins/modules/oci_network_cross_connect_group_facts.py b/plugins/modules/oci_network_cross_connect_group_facts.py index c4c754e914..48b0b0f2d1 100644 --- a/plugins/modules/oci_network_cross_connect_group_facts.py +++ b/plugins/modules/oci_network_cross_connect_group_facts.py @@ -74,10 +74,7 @@ - "INACTIVE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_cross_connect_location_facts.py b/plugins/modules/oci_network_cross_connect_location_facts.py index 83467588e1..d2e09227f9 100644 --- a/plugins/modules/oci_network_cross_connect_location_facts.py +++ b/plugins/modules/oci_network_cross_connect_location_facts.py @@ -32,10 +32,7 @@ - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_network_cross_connect_port_speed_shape_facts.py b/plugins/modules/oci_network_cross_connect_port_speed_shape_facts.py index 7f46f5307d..805e05c293 100644 --- a/plugins/modules/oci_network_cross_connect_port_speed_shape_facts.py +++ b/plugins/modules/oci_network_cross_connect_port_speed_shape_facts.py @@ -33,10 +33,7 @@ - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_network_cross_connect_status_facts.py b/plugins/modules/oci_network_cross_connect_status_facts.py index 28e9e4959d..105a5008f2 100644 --- a/plugins/modules/oci_network_cross_connect_status_facts.py +++ b/plugins/modules/oci_network_cross_connect_status_facts.py @@ -32,10 +32,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_dhcp_options.py b/plugins/modules/oci_network_dhcp_options.py index be93e36e34..95e9a2f64a 100644 --- a/plugins/modules/oci_network_dhcp_options.py +++ b/plugins/modules/oci_network_dhcp_options.py @@ -33,7 +33,8 @@ L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). - "You may optionally specify a *display name* for the set of DHCP options, otherwise a default is provided. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -142,10 +143,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -363,32 +360,37 @@ def get_resource(self): self.client.get_dhcp_options, dhcp_id=self.module.params.get("dhcp_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "vcn_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_dhcp_options, **kwargs ) diff --git a/plugins/modules/oci_network_dhcp_options_facts.py b/plugins/modules/oci_network_dhcp_options_facts.py index f4eee63f2a..6976e40019 100644 --- a/plugins/modules/oci_network_dhcp_options_facts.py +++ b/plugins/modules/oci_network_dhcp_options_facts.py @@ -80,10 +80,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_drg.py b/plugins/modules/oci_network_drg.py index 18a5bb2686..206ec574b8 100644 --- a/plugins/modules/oci_network_drg.py +++ b/plugins/modules/oci_network_drg.py @@ -33,7 +33,8 @@ For information about OCIDs, see L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). - "You may optionally specify a *display name* for the DRG, otherwise a default is provided. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -77,10 +78,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -220,29 +217,23 @@ def get_resource(self): self.client.get_drg, drg_id=self.module.params.get("drg_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_drgs, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_network_drg_attachment.py b/plugins/modules/oci_network_drg_attachment.py index 43e8e6b3e9..f693068c76 100644 --- a/plugins/modules/oci_network_drg_attachment.py +++ b/plugins/modules/oci_network_drg_attachment.py @@ -32,7 +32,8 @@ - For the purposes of access control, the DRG attachment is automatically placed into the same compartment as the VCN. For more information about compartments and access control, see L(Overview of the IAM Service,https://docs.cloud.oracle.com/Content/Identity/Concepts/overview.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: display_name: description: @@ -51,8 +52,9 @@ - If you don't specify a route table here, the DRG attachment is created without an associated route table. The Networking service does NOT automatically associate the attached VCN's default route table with the DRG attachment. - - "For information about why you would associate a route table with a DRG attachment, see - L(Advanced Scenario: Transit Routing,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." + - "For information about why you would associate a route table with a DRG attachment, see:" + - " * L(Transit Routing: Access to Multiple VCNs in Same Region,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm) + * L(Transit Routing: Private Access to Oracle Services,https://docs.cloud.oracle.com/Content/Network/Tasks/transitroutingoracleservices.htm)" type: str vcn_id: description: @@ -82,10 +84,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -162,8 +160,10 @@ route_table_id: description: - The OCID of the route table the DRG attachment is using. - - "For information about why you would associate a route table with a DRG attachment, see - L(Advanced Scenario: Transit Routing,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." + - "For information about why you would associate a route table with a DRG attachment, see:" + - " * L(Transit Routing: Access to Multiple VCNs in Same Region,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm) + * L(Transit Routing: Private Access to Oracle + Services,https://docs.cloud.oracle.com/Content/Network/Tasks/transitroutingoracleservices.htm)" returned: on success type: string sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx @@ -230,32 +230,36 @@ def get_resource(self): drg_attachment_id=self.module.params.get("drg_attachment_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "vcn_id", - "drg_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["vcn_id", "drg_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_drg_attachments, **kwargs ) diff --git a/plugins/modules/oci_network_drg_attachment_facts.py b/plugins/modules/oci_network_drg_attachment_facts.py index cf24cff7d4..c097217fe7 100644 --- a/plugins/modules/oci_network_drg_attachment_facts.py +++ b/plugins/modules/oci_network_drg_attachment_facts.py @@ -47,10 +47,7 @@ description: - The OCID of the DRG. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ @@ -106,8 +103,10 @@ route_table_id: description: - The OCID of the route table the DRG attachment is using. - - "For information about why you would associate a route table with a DRG attachment, see - L(Advanced Scenario: Transit Routing,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." + - "For information about why you would associate a route table with a DRG attachment, see:" + - " * L(Transit Routing: Access to Multiple VCNs in Same Region,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm) + * L(Transit Routing: Private Access to Oracle + Services,https://docs.cloud.oracle.com/Content/Network/Tasks/transitroutingoracleservices.htm)" returned: on success type: string sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx diff --git a/plugins/modules/oci_network_drg_facts.py b/plugins/modules/oci_network_drg_facts.py index 67b0ce4261..f7832c98d0 100644 --- a/plugins/modules/oci_network_drg_facts.py +++ b/plugins/modules/oci_network_drg_facts.py @@ -38,10 +38,7 @@ - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. - Required to list multiple drgs. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_network_fast_connect_provider_service_facts.py b/plugins/modules/oci_network_fast_connect_provider_service_facts.py index 110b53e1f8..ffc3b2df1f 100644 --- a/plugins/modules/oci_network_fast_connect_provider_service_facts.py +++ b/plugins/modules/oci_network_fast_connect_provider_service_facts.py @@ -42,10 +42,7 @@ - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. - Required to list multiple fast_connect_provider_services. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_fast_connect_provider_service_key_facts.py b/plugins/modules/oci_network_fast_connect_provider_service_key_facts.py index 076af146d5..9440e16fce 100644 --- a/plugins/modules/oci_network_fast_connect_provider_service_key_facts.py +++ b/plugins/modules/oci_network_fast_connect_provider_service_key_facts.py @@ -40,10 +40,7 @@ attribute of the L(FastConnectProviderService,https://docs.cloud.oracle.com/#/en/iaas/20160918/FastConnectProviderService/). type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_network_fast_connect_provider_service_virtual_circuit_bandwidth_shape_facts.py b/plugins/modules/oci_network_fast_connect_provider_service_virtual_circuit_bandwidth_shape_facts.py index aee2d924fb..672334ca14 100644 --- a/plugins/modules/oci_network_fast_connect_provider_service_virtual_circuit_bandwidth_shape_facts.py +++ b/plugins/modules/oci_network_fast_connect_provider_service_virtual_circuit_bandwidth_shape_facts.py @@ -34,10 +34,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_network_internet_gateway.py b/plugins/modules/oci_network_internet_gateway.py index a10496baf8..fc00c23420 100644 --- a/plugins/modules/oci_network_internet_gateway.py +++ b/plugins/modules/oci_network_internet_gateway.py @@ -40,7 +40,8 @@ traffic will flow to/from the internet even if there's a route rule that enables that traffic. You can later use L(UpdateInternetGateway,https://docs.cloud.oracle.com/#/en/iaas/20160918/InternetGateway/UpdateInternetGateway) to easily disable/enable the gateway without changing the route rule. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -96,10 +97,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -259,32 +256,37 @@ def get_resource(self): self.client.get_internet_gateway, ig_id=self.module.params.get("ig_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "vcn_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_internet_gateways, **kwargs ) diff --git a/plugins/modules/oci_network_internet_gateway_facts.py b/plugins/modules/oci_network_internet_gateway_facts.py index 6fb058601e..8b5a1faadb 100644 --- a/plugins/modules/oci_network_internet_gateway_facts.py +++ b/plugins/modules/oci_network_internet_gateway_facts.py @@ -78,10 +78,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_ip_sec_connection.py b/plugins/modules/oci_network_ip_sec_connection.py index c1d73c895e..f7b7ea962f 100644 --- a/plugins/modules/oci_network_ip_sec_connection.py +++ b/plugins/modules/oci_network_ip_sec_connection.py @@ -46,7 +46,8 @@ - For each tunnel, you need the IP address of Oracle's VPN headend and the shared secret (that is, the pre-shared key). For more information, see L(Configuring Your On-Premises Router for an IPSec VPN,https://docs.cloud.oracle.com/Content/Network/Tasks/configuringCPE.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -84,6 +85,26 @@ Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). - "Example: `{\\"Department\\": \\"Finance\\"}`" type: dict + cpe_local_identifier: + description: + - Your identifier for your CPE device. Can be either an IP address or a hostname (specifically, the + fully qualified domain name (FQDN)). The type of identifier you provide here must correspond + to the value for `cpeLocalIdentifierType`. + - If you don't provide a value, the `ipAddress` attribute for the L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) + object specified by `cpeId` is used as the `cpeLocalIdentifier`. + - For information about why you'd provide this value, see + L(If Your CPE Is Behind a NAT Device,https://docs.cloud.oracle.com/Content/Network/Tasks/overviewIPsec.htm#nat). + - "Example IP address: `10.0.3.3`" + - "Example hostname: `cpe.example.com`" + type: str + cpe_local_identifier_type: + description: + - The type of identifier for your CPE device. The value you provide here must correspond to the value + for `cpeLocalIdentifier`. + type: str + choices: + - "IP_ADDRESS" + - "HOSTNAME" static_routes: description: - Static routes to the CPE. A static route's CIDR must not be a @@ -116,6 +137,13 @@ choices: - "BGP" - "STATIC" + ike_version: + description: + - Internet Key Exchange protocol version. + type: str + choices: + - "V1" + - "V2" shared_secret: description: - The shared secret (pre-shared key) to use for the IPSec tunnel. Only numbers, letters, and @@ -181,10 +209,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -204,6 +228,9 @@ defined_tags: {'Operations': {'CostCenter': 'US'}} display_name: MyIPSecConnection freeform_tags: {'Department': 'Finance'} + cpe_local_identifier: cpe_local_identifier_example + cpe_local_identifier_type: IP_ADDRESS + static_routes: [ "172.16.10.0/24" ] - name: Update ip_sec_connection oci_network_ip_sec_connection: @@ -285,6 +312,27 @@ returned: on success type: string sample: PROVISIONING + cpe_local_identifier: + description: + - Your identifier for your CPE device. Can be either an IP address or a hostname (specifically, + the fully qualified domain name (FQDN)). The type of identifier here must correspond + to the value for `cpeLocalIdentifierType`. + - If you don't provide a value when creating the IPSec connection, the `ipAddress` attribute + for the L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) object specified by `cpeId` is used as the `cpeLocalIdentifier`. + - For information about why you'd provide this value, see + L(If Your CPE Is Behind a NAT Device,https://docs.cloud.oracle.com/Content/Network/Tasks/overviewIPsec.htm#nat). + - "Example IP address: `10.0.3.3`" + - "Example hostname: `cpe.example.com`" + returned: on success + type: string + sample: cpe_local_identifier_example + cpe_local_identifier_type: + description: + - The type of identifier for your CPE device. The value here must correspond to the value + for `cpeLocalIdentifier`. + returned: on success + type: string + sample: IP_ADDRESS static_routes: description: - Static routes to the CPE. The CIDR must not be a @@ -313,6 +361,8 @@ "freeform_tags": {'Department': 'Finance'}, "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", "lifecycle_state": "PROVISIONING", + "cpe_local_identifier": "cpe_local_identifier_example", + "cpe_local_identifier_type": "IP_ADDRESS", "static_routes": [], "time_created": "2016-08-25T21:10:29.600Z" } @@ -356,32 +406,36 @@ def get_resource(self): ipsc_id=self.module.params.get("ipsc_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "drg_id", - "cpe_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["drg_id", "cpe_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_ip_sec_connections, **kwargs ) @@ -453,6 +507,10 @@ def main(): display_name=dict(aliases=["name"], type="str"), drg_id=dict(type="str"), freeform_tags=dict(type="dict"), + cpe_local_identifier=dict(type="str"), + cpe_local_identifier_type=dict( + type="str", choices=["IP_ADDRESS", "HOSTNAME"] + ), static_routes=dict(type="list"), tunnel_configuration=dict( type="list", @@ -460,6 +518,7 @@ def main(): options=dict( display_name=dict(aliases=["name"], type="str"), routing=dict(type="str", choices=["BGP", "STATIC"]), + ike_version=dict(type="str", choices=["V1", "V2"]), shared_secret=dict(type="str"), bgp_session_config=dict( type="dict", diff --git a/plugins/modules/oci_network_ip_sec_connection_cpe_config_content_facts.py b/plugins/modules/oci_network_ip_sec_connection_cpe_config_content_facts.py new file mode 100644 index 0000000000..a30f92698d --- /dev/null +++ b/plugins/modules/oci_network_ip_sec_connection_cpe_config_content_facts.py @@ -0,0 +1,142 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_network_ip_sec_connection_cpe_config_content_facts +short_description: Fetches details about a IpSecConnectionCpeConfigContent resource in Oracle Cloud Infrastructure +description: + - Fetches details about a IpSecConnectionCpeConfigContent resource in Oracle Cloud Infrastructure + - Renders a set of CPE configuration content for the specified IPSec connection (for all the + tunnels in the connection). The content helps a network engineer configure the actual CPE + device (for example, a hardware router) that the specified IPSec connection terminates on. + - The rendered content is specific to the type of CPE device (for example, Cisco ASA). Therefore the + L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) used by the specified + L(IPSecConnection,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/) + must have the CPE's device type specified by the `cpeDeviceShapeId` attribute. The content + optionally includes answers that the customer provides (see + L(UpdateTunnelCpeDeviceConfig,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/UpdateTunnelCpeDeviceConfig)), + merged with a template of other information specific to the CPE device type. + - "The operation returns configuration information for all tunnels in the single specified + L(IPSecConnection,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/) object. Here are other similar + operations:" + - " * L(GetTunnelCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfigContent) + returns CPE configuration content for a specific tunnel within an IPSec connection. + * L(GetCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/GetCpeDeviceConfigContent) + returns CPE configuration content for *all* IPSec connections that use a specific CPE." +version_added: "2.5" +options: + ipsc_id: + description: + - The OCID of the IPSec connection. + type: str + aliases: ["id"] + required: true +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific ip_sec_connection_cpe_config_content + oci_network_ip_sec_connection_cpe_config_content_facts: + ipsc_id: ocid1.ipsc.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +ip_sec_connection_cpe_config_content: + description: + - IpSecConnectionCpeConfigContent resource + returned: on success + type: str + sample: "sample" +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import VirtualNetworkClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class IpSecConnectionCpeConfigContentFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "ipsc_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_ipsec_cpe_device_config_content, + ipsc_id=self.module.params.get("ipsc_id"), + ) + + +IpSecConnectionCpeConfigContentFactsHelperCustom = get_custom_class( + "IpSecConnectionCpeConfigContentFactsHelperCustom" +) + + +class ResourceFactsHelper( + IpSecConnectionCpeConfigContentFactsHelperCustom, + IpSecConnectionCpeConfigContentFactsHelperGen, +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update(dict(ipsc_id=dict(aliases=["id"], type="str", required=True),)) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="ip_sec_connection_cpe_config_content", + service_client_class=VirtualNetworkClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(ip_sec_connection_cpe_config_content=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_network_ip_sec_connection_device_config_facts.py b/plugins/modules/oci_network_ip_sec_connection_device_config_facts.py index 16e6704a02..b44201f1d0 100644 --- a/plugins/modules/oci_network_ip_sec_connection_device_config_facts.py +++ b/plugins/modules/oci_network_ip_sec_connection_device_config_facts.py @@ -35,10 +35,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_ip_sec_connection_device_status_facts.py b/plugins/modules/oci_network_ip_sec_connection_device_status_facts.py index 40f2c41626..e0e4995356 100644 --- a/plugins/modules/oci_network_ip_sec_connection_device_status_facts.py +++ b/plugins/modules/oci_network_ip_sec_connection_device_status_facts.py @@ -33,10 +33,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_ip_sec_connection_facts.py b/plugins/modules/oci_network_ip_sec_connection_facts.py index 68291416c5..a03cc6dec6 100644 --- a/plugins/modules/oci_network_ip_sec_connection_facts.py +++ b/plugins/modules/oci_network_ip_sec_connection_facts.py @@ -47,10 +47,7 @@ description: - The OCID of the CPE. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ @@ -126,6 +123,27 @@ returned: on success type: string sample: PROVISIONING + cpe_local_identifier: + description: + - Your identifier for your CPE device. Can be either an IP address or a hostname (specifically, + the fully qualified domain name (FQDN)). The type of identifier here must correspond + to the value for `cpeLocalIdentifierType`. + - If you don't provide a value when creating the IPSec connection, the `ipAddress` attribute + for the L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) object specified by `cpeId` is used as the `cpeLocalIdentifier`. + - For information about why you'd provide this value, see + L(If Your CPE Is Behind a NAT Device,https://docs.cloud.oracle.com/Content/Network/Tasks/overviewIPsec.htm#nat). + - "Example IP address: `10.0.3.3`" + - "Example hostname: `cpe.example.com`" + returned: on success + type: string + sample: cpe_local_identifier_example + cpe_local_identifier_type: + description: + - The type of identifier for your CPE device. The value here must correspond to the value + for `cpeLocalIdentifier`. + returned: on success + type: string + sample: IP_ADDRESS static_routes: description: - Static routes to the CPE. The CIDR must not be a @@ -154,6 +172,8 @@ "freeform_tags": {'Department': 'Finance'}, "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", "lifecycle_state": "PROVISIONING", + "cpe_local_identifier": "cpe_local_identifier_example", + "cpe_local_identifier_type": "IP_ADDRESS", "static_routes": [], "time_created": "2016-08-25T21:10:29.600Z" }] diff --git a/plugins/modules/oci_network_ip_sec_connection_tunnel.py b/plugins/modules/oci_network_ip_sec_connection_tunnel.py index 6146c73ed2..40b36d2da2 100644 --- a/plugins/modules/oci_network_ip_sec_connection_tunnel.py +++ b/plugins/modules/oci_network_ip_sec_connection_tunnel.py @@ -23,7 +23,8 @@ short_description: Manage an IpSecConnectionTunnel resource in Oracle Cloud Infrastructure description: - This module allows the user to update an IpSecConnectionTunnel resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: ipsc_id: description: @@ -50,6 +51,13 @@ choices: - "BGP" - "STATIC" + ike_version: + description: + - Internet Key Exchange protocol version. + type: str + choices: + - "V1" + - "V2" bgp_session_config: description: - Information for establishing a BGP session for the IPSec tunnel. @@ -99,10 +107,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ @@ -112,6 +116,7 @@ ipsc_id: ocid1.ipsc.oc1..xxxxxxEXAMPLExxxxxx display_name: display_name_example routing: BGP + ike_version: V1 - name: Update ip_sec_connection_tunnel oci_network_ip_sec_connection_tunnel: @@ -159,6 +164,12 @@ returned: on success type: string sample: UP + ike_version: + description: + - Internet Key Exchange protocol version. + returned: on success + type: string + sample: V1 lifecycle_state: description: - The tunnel's lifecycle state. @@ -253,6 +264,7 @@ "vpn_ip": "192.0.2.5", "cpe_ip": "192.0.2.157", "status": "UP", + "ike_version": "V1", "lifecycle_state": "PROVISIONING", "display_name": "display_name_example", "bgp_session_info": { @@ -306,29 +318,23 @@ def get_resource(self): tunnel_id=self.module.params.get("tunnel_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "ipsc_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_ip_sec_connection_tunnels, **kwargs ) @@ -373,6 +379,7 @@ def main(): tunnel_id=dict(aliases=["id"], type="str"), display_name=dict(aliases=["name"], type="str"), routing=dict(type="str", choices=["BGP", "STATIC"]), + ike_version=dict(type="str", choices=["V1", "V2"]), bgp_session_config=dict( type="dict", options=dict( diff --git a/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config.py b/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config.py new file mode 100644 index 0000000000..7135731248 --- /dev/null +++ b/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config.py @@ -0,0 +1,216 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_network_ip_sec_connection_tunnel_cpe_device_config +short_description: Manage an IpSecConnectionTunnelCpeDeviceConfig resource in Oracle Cloud Infrastructure +description: + - This module allows the user to update an IpSecConnectionTunnelCpeDeviceConfig resource in Oracle Cloud Infrastructure +version_added: "2.9" +author: Oracle (@oracle) +options: + ipsc_id: + description: + - The OCID of the IPSec connection. + type: str + required: true + tunnel_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the tunnel. + type: str + aliases: ["id"] + required: true + tunnel_cpe_device_config: + description: + - The set of configuration answers for a CPE device. + type: list + suboptions: + key: + description: + - A string that identifies the question to be answered. See the `key` attribute in + L(CpeDeviceConfigQuestion,https://docs.cloud.oracle.com/#/en/iaas/20160918/datatypes/CpeDeviceConfigQuestion). + type: str + value: + description: + - The answer to the question. + type: str + state: + description: + - The state of the IpSecConnectionTunnelCpeDeviceConfig. + - Use I(state=present) to update an existing an IpSecConnectionTunnelCpeDeviceConfig. + type: str + required: false + default: 'present' + choices: ["present"] +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Update ip_sec_connection_tunnel_cpe_device_config + oci_network_ip_sec_connection_tunnel_cpe_device_config: + ipsc_id: ocid1.ipsc.oc1..xxxxxxEXAMPLExxxxxx + tunnel_id: ocid1.tunnel.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +ip_sec_connection_tunnel_cpe_device_config: + description: + - Details of the IpSecConnectionTunnelCpeDeviceConfig resource acted upon by the current operation + returned: on success + type: complex + contains: + tunnel_cpe_device_config_parameter: + description: + - "" + returned: on success + type: complex + contains: + key: + description: + - A string that identifies the question to be answered. See the `key` attribute in + L(CpeDeviceConfigQuestion,https://docs.cloud.oracle.com/#/en/iaas/20160918/datatypes/CpeDeviceConfigQuestion). + returned: on success + type: string + sample: key_example + value: + description: + - The answer to the question. + returned: on success + type: string + sample: value_example + sample: { + "tunnel_cpe_device_config_parameter": [{ + "key": "key_example", + "value": "value_example" + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.core import VirtualNetworkClient + from oci.core.models import UpdateTunnelCpeDeviceConfigDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class IpSecConnectionTunnelCpeDeviceConfigHelperGen(OCIResourceHelperBase): + """Supported operations: update and get""" + + def get_module_resource_id_param(self): + return "tunnel_id" + + def get_module_resource_id(self): + return self.module.params.get("tunnel_id") + + def get_get_fn(self): + return self.client.get_tunnel_cpe_device_config + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_tunnel_cpe_device_config, + ipsc_id=self.module.params.get("ipsc_id"), + tunnel_id=self.module.params.get("tunnel_id"), + ) + + def get_update_model_class(self): + return UpdateTunnelCpeDeviceConfigDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_tunnel_cpe_device_config, + call_fn_args=(), + call_fn_kwargs=dict( + ipsc_id=self.module.params.get("ipsc_id"), + tunnel_id=self.module.params.get("tunnel_id"), + update_tunnel_cpe_device_config_details=update_details, + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + +IpSecConnectionTunnelCpeDeviceConfigHelperCustom = get_custom_class( + "IpSecConnectionTunnelCpeDeviceConfigHelperCustom" +) + + +class ResourceHelper( + IpSecConnectionTunnelCpeDeviceConfigHelperCustom, + IpSecConnectionTunnelCpeDeviceConfigHelperGen, +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=False + ) + module_args.update( + dict( + ipsc_id=dict(type="str", required=True), + tunnel_id=dict(aliases=["id"], type="str", required=True), + tunnel_cpe_device_config=dict( + type="list", + elements="dict", + options=dict(key=dict(type="str"), value=dict(type="str")), + ), + state=dict(type="str", default="present", choices=["present"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="ip_sec_connection_tunnel_cpe_device_config", + service_client_class=VirtualNetworkClient, + namespace="core", + ) + + result = dict(changed=False) + + if resource_helper.is_update(): + result = resource_helper.update() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_content_facts.py b/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_content_facts.py new file mode 100644 index 0000000000..8e9186c03a --- /dev/null +++ b/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_content_facts.py @@ -0,0 +1,156 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_network_ip_sec_connection_tunnel_cpe_device_config_content_facts +short_description: Fetches details about a IpSecConnectionTunnelCpeDeviceConfigContent resource in Oracle Cloud Infrastructure +description: + - Fetches details about a IpSecConnectionTunnelCpeDeviceConfigContent resource in Oracle Cloud Infrastructure + - Renders a set of CPE configuration content for the specified IPSec tunnel. The content helps a + network engineer configure the actual CPE device (for example, a hardware router) that the specified + IPSec tunnel terminates on. + - The rendered content is specific to the type of CPE device (for example, Cisco ASA). Therefore the + L(Cpe,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/) used by the specified + L(IPSecConnection,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/) + must have the CPE's device type specified by the `cpeDeviceShapeId` attribute. The content + optionally includes answers that the customer provides (see + L(UpdateTunnelCpeDeviceConfig,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/UpdateTunnelCpeDeviceConfig)), + merged with a template of other information specific to the CPE device type. + - "The operation returns configuration information for only the specified IPSec tunnel. + Here are other similar operations:" + - " * L(GetIpsecCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/IPSecConnection/GetIpsecCpeDeviceConfigContent) + returns CPE configuration content for all tunnels in a single IPSec connection. + * L(GetCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/Cpe/GetCpeDeviceConfigContent) + returns CPE configuration content for *all* IPSec connections that use a specific CPE." +version_added: "2.5" +options: + ipsc_id: + description: + - The OCID of the IPSec connection. + type: str + required: true + tunnel_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the tunnel. + type: str + aliases: ["id"] + required: true +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific ip_sec_connection_tunnel_cpe_device_config_content + oci_network_ip_sec_connection_tunnel_cpe_device_config_content_facts: + ipsc_id: ocid1.ipsc.oc1..xxxxxxEXAMPLExxxxxx + tunnel_id: ocid1.tunnel.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +ip_sec_connection_tunnel_cpe_device_config_content: + description: + - IpSecConnectionTunnelCpeDeviceConfigContent resource + returned: on success + type: str + sample: "sample" +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import VirtualNetworkClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class IpSecConnectionTunnelCpeDeviceConfigContentFactsHelperGen( + OCIResourceFactsHelperBase +): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "ipsc_id", + "tunnel_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_tunnel_cpe_device_config_content, + ipsc_id=self.module.params.get("ipsc_id"), + tunnel_id=self.module.params.get("tunnel_id"), + ) + + +IpSecConnectionTunnelCpeDeviceConfigContentFactsHelperCustom = get_custom_class( + "IpSecConnectionTunnelCpeDeviceConfigContentFactsHelperCustom" +) + + +class ResourceFactsHelper( + IpSecConnectionTunnelCpeDeviceConfigContentFactsHelperCustom, + IpSecConnectionTunnelCpeDeviceConfigContentFactsHelperGen, +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + ipsc_id=dict(type="str", required=True), + tunnel_id=dict(aliases=["id"], type="str", required=True), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="ip_sec_connection_tunnel_cpe_device_config_content", + service_client_class=VirtualNetworkClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(ip_sec_connection_tunnel_cpe_device_config_content=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_facts.py b/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_facts.py new file mode 100644 index 0000000000..ddeb653eed --- /dev/null +++ b/plugins/modules/oci_network_ip_sec_connection_tunnel_cpe_device_config_facts.py @@ -0,0 +1,168 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_network_ip_sec_connection_tunnel_cpe_device_config_facts +short_description: Fetches details about a IpSecConnectionTunnelCpeDeviceConfig resource in Oracle Cloud Infrastructure +description: + - Fetches details about a IpSecConnectionTunnelCpeDeviceConfig resource in Oracle Cloud Infrastructure + - Gets the set of CPE configuration answers for the tunnel, which the customer provided in + L(UpdateTunnelCpeDeviceConfig,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/UpdateTunnelCpeDeviceConfig). + To get the full set of content for the tunnel (any answers merged with the template of other + information specific to the CPE device type), use + L(GetTunnelCpeDeviceConfigContent,https://docs.cloud.oracle.com/#/en/iaas/20160918/TunnelCpeDeviceConfig/GetTunnelCpeDeviceConfigContent). +version_added: "2.5" +options: + ipsc_id: + description: + - The OCID of the IPSec connection. + type: str + required: true + tunnel_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the tunnel. + type: str + aliases: ["id"] + required: true +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific ip_sec_connection_tunnel_cpe_device_config + oci_network_ip_sec_connection_tunnel_cpe_device_config_facts: + ipsc_id: ocid1.ipsc.oc1..xxxxxxEXAMPLExxxxxx + tunnel_id: ocid1.tunnel.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +ip_sec_connection_tunnel_cpe_device_config: + description: + - IpSecConnectionTunnelCpeDeviceConfig resource + returned: on success + type: complex + contains: + tunnel_cpe_device_config_parameter: + description: + - "" + returned: on success + type: complex + contains: + key: + description: + - A string that identifies the question to be answered. See the `key` attribute in + L(CpeDeviceConfigQuestion,https://docs.cloud.oracle.com/#/en/iaas/20160918/datatypes/CpeDeviceConfigQuestion). + returned: on success + type: string + sample: key_example + value: + description: + - The answer to the question. + returned: on success + type: string + sample: value_example + sample: { + "tunnel_cpe_device_config_parameter": [{ + "key": "key_example", + "value": "value_example" + }] + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.core import VirtualNetworkClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class IpSecConnectionTunnelCpeDeviceConfigFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "ipsc_id", + "tunnel_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_tunnel_cpe_device_config, + ipsc_id=self.module.params.get("ipsc_id"), + tunnel_id=self.module.params.get("tunnel_id"), + ) + + +IpSecConnectionTunnelCpeDeviceConfigFactsHelperCustom = get_custom_class( + "IpSecConnectionTunnelCpeDeviceConfigFactsHelperCustom" +) + + +class ResourceFactsHelper( + IpSecConnectionTunnelCpeDeviceConfigFactsHelperCustom, + IpSecConnectionTunnelCpeDeviceConfigFactsHelperGen, +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + ipsc_id=dict(type="str", required=True), + tunnel_id=dict(aliases=["id"], type="str", required=True), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="ip_sec_connection_tunnel_cpe_device_config", + service_client_class=VirtualNetworkClient, + namespace="core", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(ip_sec_connection_tunnel_cpe_device_config=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_network_ip_sec_connection_tunnel_facts.py b/plugins/modules/oci_network_ip_sec_connection_tunnel_facts.py index c9cc3001a8..4bf58332de 100644 --- a/plugins/modules/oci_network_ip_sec_connection_tunnel_facts.py +++ b/plugins/modules/oci_network_ip_sec_connection_tunnel_facts.py @@ -38,10 +38,7 @@ - Required to get a specific ip_sec_connection_tunnel. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ @@ -96,6 +93,12 @@ returned: on success type: string sample: UP + ike_version: + description: + - Internet Key Exchange protocol version. + returned: on success + type: string + sample: V1 lifecycle_state: description: - The tunnel's lifecycle state. @@ -190,6 +193,7 @@ "vpn_ip": "192.0.2.5", "cpe_ip": "192.0.2.157", "status": "UP", + "ike_version": "V1", "lifecycle_state": "PROVISIONING", "display_name": "display_name_example", "bgp_session_info": { diff --git a/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret.py b/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret.py index c95cf4e22c..4a9f21614e 100644 --- a/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret.py +++ b/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret.py @@ -23,7 +23,8 @@ short_description: Manage an IpSecConnectionTunnelSharedSecret resource in Oracle Cloud Infrastructure description: - This module allows the user to update an IpSecConnectionTunnelSharedSecret resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: ipsc_id: description: @@ -50,10 +51,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret_facts.py b/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret_facts.py index c4dadd6d27..5ae34c6ff7 100644 --- a/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret_facts.py +++ b/plugins/modules/oci_network_ip_sec_connection_tunnel_shared_secret_facts.py @@ -38,10 +38,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_letter_of_authority_facts.py b/plugins/modules/oci_network_letter_of_authority_facts.py index 03d2bf3e3d..bf20a68c71 100644 --- a/plugins/modules/oci_network_letter_of_authority_facts.py +++ b/plugins/modules/oci_network_letter_of_authority_facts.py @@ -32,10 +32,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_local_peering_gateway.py b/plugins/modules/oci_network_local_peering_gateway.py index 073b735554..e7f09fdecb 100644 --- a/plugins/modules/oci_network_local_peering_gateway.py +++ b/plugins/modules/oci_network_local_peering_gateway.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a LocalPeeringGateway resource in Oracle Cloud Infrastructure - For I(state=present), creates a new local peering gateway (LPG) for the specified VCN. - "This resource has the following action operations in the M(oci_local_peering_gateway_actions) module: connect." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -61,7 +62,7 @@ table. The Networking service does NOT automatically associate the attached VCN's default route table with the LPG. - "For information about why you would associate a route table with an LPG, see - L(Advanced Scenario: Transit Routing,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." + L(Transit Routing: Access to Multiple VCNs in Same Region,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." type: str vcn_id: description: @@ -86,10 +87,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -221,7 +218,7 @@ description: - The OCID of the route table the LPG is using. - "For information about why you would associate a route table with an LPG, see - L(Advanced Scenario: Transit Routing,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." + L(Transit Routing: Access to Multiple VCNs in Same Region,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." returned: on success type: string sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx @@ -294,30 +291,24 @@ def get_resource(self): local_peering_gateway_id=self.module.params.get("local_peering_gateway_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "vcn_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_local_peering_gateways, **kwargs ) diff --git a/plugins/modules/oci_network_local_peering_gateway_actions.py b/plugins/modules/oci_network_local_peering_gateway_actions.py index 5a6185ba91..3d124fd40d 100644 --- a/plugins/modules/oci_network_local_peering_gateway_actions.py +++ b/plugins/modules/oci_network_local_peering_gateway_actions.py @@ -48,11 +48,9 @@ - The action to perform on the LocalPeeringGateway. type: str required: true - choices: ["connect"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "connect" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -158,7 +156,7 @@ description: - The OCID of the route table the LPG is using. - "For information about why you would associate a route table with an LPG, see - L(Advanced Scenario: Transit Routing,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." + L(Transit Routing: Access to Multiple VCNs in Same Region,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." returned: on success type: string sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx diff --git a/plugins/modules/oci_network_local_peering_gateway_facts.py b/plugins/modules/oci_network_local_peering_gateway_facts.py index e68435709c..3f0e56ad7e 100644 --- a/plugins/modules/oci_network_local_peering_gateway_facts.py +++ b/plugins/modules/oci_network_local_peering_gateway_facts.py @@ -44,10 +44,7 @@ - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the VCN. - Required to list multiple local_peering_gateways. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ @@ -156,7 +153,7 @@ description: - The OCID of the route table the LPG is using. - "For information about why you would associate a route table with an LPG, see - L(Advanced Scenario: Transit Routing,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." + L(Transit Routing: Access to Multiple VCNs in Same Region,https://docs.cloud.oracle.com/Content/Network/Tasks/transitrouting.htm)." returned: on success type: string sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx diff --git a/plugins/modules/oci_network_nat_gateway.py b/plugins/modules/oci_network_nat_gateway.py index 397c857f8c..3f150dfd19 100644 --- a/plugins/modules/oci_network_nat_gateway.py +++ b/plugins/modules/oci_network_nat_gateway.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a NatGateway resource in Oracle Cloud Infrastructure - For I(state=present), creates a new NAT gateway for the specified VCN. You must also set up a route rule with the NAT gateway as the rule's target. See L(Route Table,https://docs.cloud.oracle.com/#/en/iaas/20160918/RouteTable/). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -81,10 +82,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -250,32 +247,36 @@ def get_resource(self): nat_gateway_id=self.module.params.get("nat_gateway_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "vcn_id", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["vcn_id", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_nat_gateways, **kwargs ) diff --git a/plugins/modules/oci_network_nat_gateway_facts.py b/plugins/modules/oci_network_nat_gateway_facts.py index 727992c526..39fc817700 100644 --- a/plugins/modules/oci_network_nat_gateway_facts.py +++ b/plugins/modules/oci_network_nat_gateway_facts.py @@ -78,10 +78,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_peer_region_for_remote_peering_facts.py b/plugins/modules/oci_network_peer_region_for_remote_peering_facts.py index d355e34fcf..2a19869875 100644 --- a/plugins/modules/oci_network_peer_region_for_remote_peering_facts.py +++ b/plugins/modules/oci_network_peer_region_for_remote_peering_facts.py @@ -27,10 +27,7 @@ For more information, see L(VCN Peering,https://docs.cloud.oracle.com/Content/Network/Tasks/VCNpeering.htm). version_added: "2.5" options: {} -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_network_private_ip.py b/plugins/modules/oci_network_private_ip.py index 1191d32693..34e2a7ecd1 100644 --- a/plugins/modules/oci_network_private_ip.py +++ b/plugins/modules/oci_network_private_ip.py @@ -26,7 +26,8 @@ - For I(state=present), creates a secondary private IP for the specified VNIC. For more information about secondary private IPs, see L(IP Addresses,https://docs.cloud.oracle.com/Content/Network/Tasks/managingIPaddresses.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: defined_tags: description: @@ -89,10 +90,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -282,30 +279,34 @@ def get_resource(self): private_ip_id=self.module.params.get("private_ip_id"), ) - def list_resources(self): - required_list_method_params = [] - - optional_list_method_params = [ - "ip_address", - "vnic_id", - ] + def get_required_kwargs_for_list(self): + return dict() - required_kwargs = dict( - (param, self.module.params[param]) for param in required_list_method_params + def get_optional_kwargs_for_list(self): + optional_list_method_params = ( + ["ip_address"] + if self._use_name_as_identifier() + else ["ip_address", "vnic_id"] ) - optional_kwargs = dict( + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_private_ips, **kwargs ) diff --git a/plugins/modules/oci_network_private_ip_facts.py b/plugins/modules/oci_network_private_ip_facts.py index 627b145f13..78b343b9be 100644 --- a/plugins/modules/oci_network_private_ip_facts.py +++ b/plugins/modules/oci_network_private_ip_facts.py @@ -56,10 +56,7 @@ description: - The OCID of the VNIC. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_network_public_ip.py b/plugins/modules/oci_network_public_ip.py index a9c0ba6d78..34534298ff 100644 --- a/plugins/modules/oci_network_public_ip.py +++ b/plugins/modules/oci_network_public_ip.py @@ -40,7 +40,8 @@ - Also, for reserved public IPs, the optional assignment part of this operation is asynchronous. Poll the public IP's `lifecycleState` to determine if the assignment succeeded. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -122,10 +123,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -349,32 +346,37 @@ def get_resource(self): public_ip_id=self.module.params.get("public_ip_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "scope", "compartment_id", ] - optional_list_method_params = [ - "lifetime", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["lifetime"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_public_ips, **kwargs ) diff --git a/plugins/modules/oci_network_public_ip_facts.py b/plugins/modules/oci_network_public_ip_facts.py index 80f9900708..8485f7cc18 100644 --- a/plugins/modules/oci_network_public_ip_facts.py +++ b/plugins/modules/oci_network_public_ip_facts.py @@ -88,10 +88,7 @@ description: - OCID of the private IP that the public IP is assigned to. Use I(private_ip_id) to retrieve information of a public IP assigned to it. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_network_remote_peering_connection.py b/plugins/modules/oci_network_remote_peering_connection.py index 4eb3de0a21..b7fbea825a 100644 --- a/plugins/modules/oci_network_remote_peering_connection.py +++ b/plugins/modules/oci_network_remote_peering_connection.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a RemotePeeringConnection resource in Oracle Cloud Infrastructure - For I(state=present), creates a new remote peering connection (RPC) for the specified DRG. - "This resource has the following action operations in the M(oci_remote_peering_connection_actions) module: connect." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -75,10 +76,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -267,31 +264,36 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "drg_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["drg_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_remote_peering_connections, **kwargs ) diff --git a/plugins/modules/oci_network_remote_peering_connection_actions.py b/plugins/modules/oci_network_remote_peering_connection_actions.py index 2b87792c0e..230fedf8d0 100644 --- a/plugins/modules/oci_network_remote_peering_connection_actions.py +++ b/plugins/modules/oci_network_remote_peering_connection_actions.py @@ -54,11 +54,9 @@ - The action to perform on the RemotePeeringConnection. type: str required: true - choices: ["connect"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "connect" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_remote_peering_connection_facts.py b/plugins/modules/oci_network_remote_peering_connection_facts.py index 06f9642704..942f466aed 100644 --- a/plugins/modules/oci_network_remote_peering_connection_facts.py +++ b/plugins/modules/oci_network_remote_peering_connection_facts.py @@ -43,10 +43,7 @@ description: - The OCID of the DRG. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_network_route_table.py b/plugins/modules/oci_network_route_table.py index d0cf01dceb..6f304c0b66 100644 --- a/plugins/modules/oci_network_route_table.py +++ b/plugins/modules/oci_network_route_table.py @@ -36,7 +36,8 @@ L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). - "You may optionally specify a *display name* for the route table, otherwise a default is provided. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -133,10 +134,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -350,32 +347,37 @@ def get_resource(self): self.client.get_route_table, rt_id=self.module.params.get("rt_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "vcn_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_route_tables, **kwargs ) diff --git a/plugins/modules/oci_network_route_table_facts.py b/plugins/modules/oci_network_route_table_facts.py index 9767ea1078..43d2e486f8 100644 --- a/plugins/modules/oci_network_route_table_facts.py +++ b/plugins/modules/oci_network_route_table_facts.py @@ -80,10 +80,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_security_group.py b/plugins/modules/oci_network_security_group.py index 23819add92..23cc4d2344 100644 --- a/plugins/modules/oci_network_security_group.py +++ b/plugins/modules/oci_network_security_group.py @@ -24,7 +24,8 @@ description: - This module allows the user to create, update and delete a NetworkSecurityGroup resource in Oracle Cloud Infrastructure - For I(state=present), creates a new network security group for the specified VCN. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -76,10 +77,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -229,32 +226,36 @@ def get_resource(self): ), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "vcn_id", - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["vcn_id", "display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_network_security_groups, **kwargs ) diff --git a/plugins/modules/oci_network_security_group_facts.py b/plugins/modules/oci_network_security_group_facts.py index 698e20f879..548a4b0101 100644 --- a/plugins/modules/oci_network_security_group_facts.py +++ b/plugins/modules/oci_network_security_group_facts.py @@ -77,10 +77,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_security_group_security_rule_actions.py b/plugins/modules/oci_network_security_group_security_rule_actions.py index 90374633e6..d7b8933b3a 100644 --- a/plugins/modules/oci_network_security_group_security_rule_actions.py +++ b/plugins/modules/oci_network_security_group_security_rule_actions.py @@ -241,11 +241,11 @@ - The action to perform on the NetworkSecurityGroupSecurityRule. type: str required: true - choices: ["add", "remove", "update"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "add" + - "remove" + - "update" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_security_group_security_rule_facts.py b/plugins/modules/oci_network_security_group_security_rule_facts.py index deceb3878a..c9686d7a32 100644 --- a/plugins/modules/oci_network_security_group_security_rule_facts.py +++ b/plugins/modules/oci_network_security_group_security_rule_facts.py @@ -53,10 +53,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_security_group_vnic_facts.py b/plugins/modules/oci_network_security_group_vnic_facts.py index ebb5c78316..513a767f6e 100644 --- a/plugins/modules/oci_network_security_group_vnic_facts.py +++ b/plugins/modules/oci_network_security_group_vnic_facts.py @@ -45,10 +45,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_security_list.py b/plugins/modules/oci_network_security_list.py index e9c154a3a3..d903a0cdbf 100644 --- a/plugins/modules/oci_network_security_list.py +++ b/plugins/modules/oci_network_security_list.py @@ -35,7 +35,8 @@ L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). - "You may optionally specify a *display name* for the security list, otherwise a default is provided. It does not have to be unique, and you can change it. Avoid entering confidential information." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -403,10 +404,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -992,32 +989,37 @@ def get_resource(self): security_list_id=self.module.params.get("security_list_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "vcn_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_security_lists, **kwargs ) diff --git a/plugins/modules/oci_network_security_list_facts.py b/plugins/modules/oci_network_security_list_facts.py index d758b8d880..736a4e254b 100644 --- a/plugins/modules/oci_network_security_list_facts.py +++ b/plugins/modules/oci_network_security_list_facts.py @@ -78,10 +78,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_service_facts.py b/plugins/modules/oci_network_service_facts.py index e8f20c0a42..c50a253dc8 100644 --- a/plugins/modules/oci_network_service_facts.py +++ b/plugins/modules/oci_network_service_facts.py @@ -34,10 +34,7 @@ - Required to get a specific service. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_network_service_gateway.py b/plugins/modules/oci_network_service_gateway.py index 4283ce821f..826aaa7226 100644 --- a/plugins/modules/oci_network_service_gateway.py +++ b/plugins/modules/oci_network_service_gateway.py @@ -31,7 +31,8 @@ - "You may optionally specify a *display name* for the service gateway, otherwise a default is provided. It does not have to be unique, and you can change it. Avoid entering confidential information." - "This resource has the following action operations in the M(oci_service_gateway_actions) module: attach_service_id, detach_service_id." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -60,6 +61,15 @@ Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). - "Example: `{\\"Department\\": \\"Finance\\"}`" type: dict + route_table_id: + description: + - The OCID of the route table the service gateway will use. + - If you don't specify a route table here, the service gateway is created without an associated route + table. The Networking service does NOT automatically associate the attached VCN's default route table + with the service gateway. + - "For information about why you would associate a route table with a service gateway, see + L(Transit Routing: Private Access to Oracle Services,https://docs.cloud.oracle.com/Content/Network/Tasks/transitroutingoracleservices.htm)." + type: str services: description: - List of the OCIDs of the L(Service,https://docs.cloud.oracle.com/#/en/iaas/20160918/Service/) objects to @@ -106,10 +116,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -127,6 +133,7 @@ defined_tags: {'Operations': {'CostCenter': 'US'}} display_name: display_name_example freeform_tags: {'Department': 'Finance'} + route_table_id: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx services: - service_id: ocid1.service.oc1..xxxxxxEXAMPLExxxxxx block_traffic: true @@ -208,6 +215,14 @@ returned: on success type: string sample: PROVISIONING + route_table_id: + description: + - "The OCID of the route table the service gateway is using. + For information about why you would associate a route table with a service gateway, see + L(Transit Routing: Private Access to Oracle Services,https://docs.cloud.oracle.com/Content/Network/Tasks/transitroutingoracleservices.htm)." + returned: on success + type: string + sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx services: description: - List of the L(Service,https://docs.cloud.oracle.com/#/en/iaas/20160918/Service/) objects enabled for this service gateway. @@ -251,6 +266,7 @@ "freeform_tags": {'Department': 'Finance'}, "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", "lifecycle_state": "PROVISIONING", + "route_table_id": "ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx", "services": [{ "service_id": "ocid1.service.oc1..xxxxxxEXAMPLExxxxxx", "service_name": "service_name_example" @@ -298,31 +314,36 @@ def get_resource(self): service_gateway_id=self.module.params.get("service_gateway_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "vcn_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["vcn_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_service_gateways, **kwargs ) @@ -394,6 +415,7 @@ def main(): defined_tags=dict(type="dict"), display_name=dict(aliases=["name"], type="str"), freeform_tags=dict(type="dict"), + route_table_id=dict(type="str"), services=dict( type="list", elements="dict", diff --git a/plugins/modules/oci_network_service_gateway_actions.py b/plugins/modules/oci_network_service_gateway_actions.py index 0fd34ee1fa..bba6466e1a 100644 --- a/plugins/modules/oci_network_service_gateway_actions.py +++ b/plugins/modules/oci_network_service_gateway_actions.py @@ -62,11 +62,10 @@ - The action to perform on the ServiceGateway. type: str required: true - choices: ["attach_service_id", "detach_service_id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "attach_service_id" + - "detach_service_id" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ @@ -143,6 +142,14 @@ returned: on success type: string sample: PROVISIONING + route_table_id: + description: + - "The OCID of the route table the service gateway is using. + For information about why you would associate a route table with a service gateway, see + L(Transit Routing: Private Access to Oracle Services,https://docs.cloud.oracle.com/Content/Network/Tasks/transitroutingoracleservices.htm)." + returned: on success + type: string + sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx services: description: - List of the L(Service,https://docs.cloud.oracle.com/#/en/iaas/20160918/Service/) objects enabled for this service gateway. @@ -186,6 +193,7 @@ "freeform_tags": {'Department': 'Finance'}, "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", "lifecycle_state": "PROVISIONING", + "route_table_id": "ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx", "services": [{ "service_id": "ocid1.service.oc1..xxxxxxEXAMPLExxxxxx", "service_name": "service_name_example" diff --git a/plugins/modules/oci_network_service_gateway_facts.py b/plugins/modules/oci_network_service_gateway_facts.py index 192e4f38ac..cece6a8666 100644 --- a/plugins/modules/oci_network_service_gateway_facts.py +++ b/plugins/modules/oci_network_service_gateway_facts.py @@ -73,10 +73,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ @@ -149,6 +146,14 @@ returned: on success type: string sample: PROVISIONING + route_table_id: + description: + - "The OCID of the route table the service gateway is using. + For information about why you would associate a route table with a service gateway, see + L(Transit Routing: Private Access to Oracle Services,https://docs.cloud.oracle.com/Content/Network/Tasks/transitroutingoracleservices.htm)." + returned: on success + type: string + sample: ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx services: description: - List of the L(Service,https://docs.cloud.oracle.com/#/en/iaas/20160918/Service/) objects enabled for this service gateway. @@ -192,6 +197,7 @@ "freeform_tags": {'Department': 'Finance'}, "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", "lifecycle_state": "PROVISIONING", + "route_table_id": "ocid1.routetable.oc1..xxxxxxEXAMPLExxxxxx", "services": [{ "service_id": "ocid1.service.oc1..xxxxxxEXAMPLExxxxxx", "service_name": "service_name_example" diff --git a/plugins/modules/oci_network_subnet.py b/plugins/modules/oci_network_subnet.py index 90d413b015..9801d0bbf4 100644 --- a/plugins/modules/oci_network_subnet.py +++ b/plugins/modules/oci_network_subnet.py @@ -48,7 +48,8 @@ - You can also add a DNS label for the subnet, which is required if you want the Internet and VCN Resolver to resolve hostnames for instances in the subnet. For more information, see L(DNS in Your Virtual Cloud Network,https://docs.cloud.oracle.com/Content/Network/Concepts/dns.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: availability_domain: description: @@ -161,10 +162,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -422,32 +419,37 @@ def get_resource(self): self.client.get_subnet, subnet_id=self.module.params.get("subnet_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", "vcn_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_subnets, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_network_subnet_facts.py b/plugins/modules/oci_network_subnet_facts.py index c39def758c..4f4b1cbc4e 100644 --- a/plugins/modules/oci_network_subnet_facts.py +++ b/plugins/modules/oci_network_subnet_facts.py @@ -78,10 +78,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_vcn.py b/plugins/modules/oci_network_vcn.py index de6260ffcf..7b4f8ffe0c 100644 --- a/plugins/modules/oci_network_vcn.py +++ b/plugins/modules/oci_network_vcn.py @@ -46,7 +46,8 @@ - The VCN and subnets you create are not accessible until you attach an internet gateway or set up an IPSec VPN or FastConnect. For more information, see L(Overview of the Networking Service,https://docs.cloud.oracle.com/Content/Network/Concepts/overview.htm). -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: cidr_block: description: @@ -111,10 +112,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -311,31 +308,36 @@ def get_resource(self): self.client.get_vcn, vcn_id=self.module.params.get("vcn_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_vcns, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_network_vcn_facts.py b/plugins/modules/oci_network_vcn_facts.py index 291cdfaaf8..14a4e3db0f 100644 --- a/plugins/modules/oci_network_vcn_facts.py +++ b/plugins/modules/oci_network_vcn_facts.py @@ -73,10 +73,7 @@ - "AVAILABLE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_virtual_circuit.py b/plugins/modules/oci_network_virtual_circuit.py index 7676836f56..e165039cd8 100644 --- a/plugins/modules/oci_network_virtual_circuit.py +++ b/plugins/modules/oci_network_virtual_circuit.py @@ -43,7 +43,8 @@ L(Route Tables,https://docs.cloud.oracle.com/Content/Network/Tasks/managingroutetables.htm)." - "This resource has the following action operations in the M(oci_virtual_circuit_actions) module: bulk_add_virtual_circuit_public_prefixes, bulk_delete_virtual_circuit_public_prefixes." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: bandwidth_shape_name: description: @@ -108,9 +109,16 @@ type: int customer_bgp_asn: description: - - Your BGP ASN (either public or private). Provide this value only if + - Deprecated. Instead use `customerAsn`. + If you specify values for both, the request will be rejected. + type: int + customer_asn: + description: + - "Your BGP ASN (either public or private). Provide this value only if there's a BGP session that goes from your edge router to Oracle. Otherwise, leave this empty or null. + Can be a 2-byte or 4-byte ASN. Uses \\"asplain\\" format." + - "Example: `12345` (2-byte) or `1587232876` (4-byte)" type: int defined_tags: description: @@ -220,10 +228,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -238,6 +242,7 @@ bandwidth_shape_name: 10 Gbps compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx customer_bgp_asn: 56 + customer_asn: 12345 defined_tags: {'Operations': {'CostCenter': 'US'}} display_name: display_name_example freeform_tags: {'Department': 'Finance'} @@ -360,11 +365,19 @@ sample: 200 customer_bgp_asn: description: - - The BGP ASN of the network at the other end of the BGP + - Deprecated. Instead use `customerAsn`. + If you specify values for both, the request will be rejected. + returned: on success + type: int + sample: 56 + customer_asn: + description: + - "The BGP ASN of the network at the other end of the BGP session from Oracle. If the session is between the customer's edge router and Oracle, the value is the customer's ASN. If the BGP session is between the provider's edge router and Oracle, the value is the provider's ASN. + Can be a 2-byte or 4-byte ASN. Uses \\"asplain\\" format." returned: on success type: int sample: 56 @@ -508,6 +521,7 @@ "vlan": 200 }], "customer_bgp_asn": 56, + "customer_asn": 56, "defined_tags": {'Operations': {'CostCenter': 'US'}}, "display_name": "display_name_example", "freeform_tags": {'Department': 'Finance'}, @@ -567,31 +581,36 @@ def get_resource(self): virtual_circuit_id=self.module.params.get("virtual_circuit_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "display_name", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["display_name"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_virtual_circuits, **kwargs ) @@ -673,6 +692,7 @@ def main(): ), ), customer_bgp_asn=dict(type="int"), + customer_asn=dict(type="int"), defined_tags=dict(type="dict"), display_name=dict(aliases=["name"], type="str"), freeform_tags=dict(type="dict"), diff --git a/plugins/modules/oci_network_virtual_circuit_actions.py b/plugins/modules/oci_network_virtual_circuit_actions.py index 702c213ccf..1217f2a717 100644 --- a/plugins/modules/oci_network_virtual_circuit_actions.py +++ b/plugins/modules/oci_network_virtual_circuit_actions.py @@ -56,11 +56,10 @@ - The action to perform on the VirtualCircuit. type: str required: true - choices: ["bulk_add_virtual_circuit_public_prefixes", "bulk_delete_virtual_circuit_public_prefixes"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "bulk_add_virtual_circuit_public_prefixes" + - "bulk_delete_virtual_circuit_public_prefixes" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -177,11 +176,19 @@ sample: 200 customer_bgp_asn: description: - - The BGP ASN of the network at the other end of the BGP + - Deprecated. Instead use `customerAsn`. + If you specify values for both, the request will be rejected. + returned: on success + type: int + sample: 56 + customer_asn: + description: + - "The BGP ASN of the network at the other end of the BGP session from Oracle. If the session is between the customer's edge router and Oracle, the value is the customer's ASN. If the BGP session is between the provider's edge router and Oracle, the value is the provider's ASN. + Can be a 2-byte or 4-byte ASN. Uses \\"asplain\\" format." returned: on success type: int sample: 56 @@ -325,6 +332,7 @@ "vlan": 200 }], "customer_bgp_asn": 56, + "customer_asn": 56, "defined_tags": {'Operations': {'CostCenter': 'US'}}, "display_name": "display_name_example", "freeform_tags": {'Department': 'Finance'}, diff --git a/plugins/modules/oci_network_virtual_circuit_bandwidth_shape_facts.py b/plugins/modules/oci_network_virtual_circuit_bandwidth_shape_facts.py index 30402ac105..130fa53760 100644 --- a/plugins/modules/oci_network_virtual_circuit_bandwidth_shape_facts.py +++ b/plugins/modules/oci_network_virtual_circuit_bandwidth_shape_facts.py @@ -32,10 +32,7 @@ - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the compartment. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_network_virtual_circuit_facts.py b/plugins/modules/oci_network_virtual_circuit_facts.py index a193eced47..f049b95d9a 100644 --- a/plugins/modules/oci_network_virtual_circuit_facts.py +++ b/plugins/modules/oci_network_virtual_circuit_facts.py @@ -77,10 +77,7 @@ - "INACTIVE" - "TERMINATING" - "TERMINATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -191,11 +188,19 @@ sample: 200 customer_bgp_asn: description: - - The BGP ASN of the network at the other end of the BGP + - Deprecated. Instead use `customerAsn`. + If you specify values for both, the request will be rejected. + returned: on success + type: int + sample: 56 + customer_asn: + description: + - "The BGP ASN of the network at the other end of the BGP session from Oracle. If the session is between the customer's edge router and Oracle, the value is the customer's ASN. If the BGP session is between the provider's edge router and Oracle, the value is the provider's ASN. + Can be a 2-byte or 4-byte ASN. Uses \\"asplain\\" format." returned: on success type: int sample: 56 @@ -339,6 +344,7 @@ "vlan": 200 }], "customer_bgp_asn": 56, + "customer_asn": 56, "defined_tags": {'Operations': {'CostCenter': 'US'}}, "display_name": "display_name_example", "freeform_tags": {'Department': 'Finance'}, diff --git a/plugins/modules/oci_network_virtual_circuit_public_prefix_facts.py b/plugins/modules/oci_network_virtual_circuit_public_prefix_facts.py index 0e0dbd2efc..e7acfa1eb7 100644 --- a/plugins/modules/oci_network_virtual_circuit_public_prefix_facts.py +++ b/plugins/modules/oci_network_virtual_circuit_public_prefix_facts.py @@ -42,10 +42,7 @@ - "IN_PROGRESS" - "COMPLETED" - "FAILED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_network_vnic.py b/plugins/modules/oci_network_vnic.py index ed1efc3a9f..ec522d5a47 100644 --- a/plugins/modules/oci_network_vnic.py +++ b/plugins/modules/oci_network_vnic.py @@ -23,7 +23,8 @@ short_description: Manage a Vnic resource in Oracle Cloud Infrastructure description: - This module allows the user to update a Vnic resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: vnic_id: description: @@ -88,10 +89,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_network_vnic_facts.py b/plugins/modules/oci_network_vnic_facts.py index 88ef265304..b5c90f48bf 100644 --- a/plugins/modules/oci_network_vnic_facts.py +++ b/plugins/modules/oci_network_vnic_facts.py @@ -35,10 +35,7 @@ type: str aliases: ["id"] required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_object_storage_bucket.py b/plugins/modules/oci_object_storage_bucket.py index f8b5a395b6..bb22243871 100644 --- a/plugins/modules/oci_object_storage_bucket.py +++ b/plugins/modules/oci_object_storage_bucket.py @@ -26,7 +26,8 @@ - For I(state=present), creates a bucket in the given namespace with a bucket name and optional user-defined metadata. Avoid entering confidential information in bucket names. - "This resource has the following action operations in the M(oci_bucket_actions) module: make_bucket_writable, reencrypt." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: namespace_name: description: @@ -113,10 +114,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -351,30 +348,24 @@ def get_resource(self): bucket_name=self.module.params.get("name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "namespace_name", "compartment_id", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_buckets, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_object_storage_bucket_actions.py b/plugins/modules/oci_object_storage_bucket_actions.py index fdf8ce9630..0319190210 100644 --- a/plugins/modules/oci_object_storage_bucket_actions.py +++ b/plugins/modules/oci_object_storage_bucket_actions.py @@ -59,11 +59,10 @@ - The action to perform on the Bucket. type: str required: true - choices: ["make_bucket_writable", "reencrypt"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "make_bucket_writable" + - "reencrypt" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_object_storage_bucket_facts.py b/plugins/modules/oci_object_storage_bucket_facts.py index c17f2b578b..9713173eb9 100644 --- a/plugins/modules/oci_object_storage_bucket_facts.py +++ b/plugins/modules/oci_object_storage_bucket_facts.py @@ -57,10 +57,7 @@ - The ID of the compartment in which to list buckets. - Required to list multiple buckets. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_namespace_facts.py b/plugins/modules/oci_object_storage_namespace_facts.py index b4400a7627..0a6ea8e31d 100644 --- a/plugins/modules/oci_object_storage_namespace_facts.py +++ b/plugins/modules/oci_object_storage_namespace_facts.py @@ -38,10 +38,7 @@ L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) within the tenancy whose Object Storage namespace is to be retrieved. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_namespace_metadata.py b/plugins/modules/oci_object_storage_namespace_metadata.py index aa5704297e..77761add70 100644 --- a/plugins/modules/oci_object_storage_namespace_metadata.py +++ b/plugins/modules/oci_object_storage_namespace_metadata.py @@ -23,7 +23,8 @@ short_description: Manage a NamespaceMetadata resource in Oracle Cloud Infrastructure description: - This module allows the user to update a NamespaceMetadata resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: namespace_name: description: @@ -46,10 +47,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_namespace_metadata_facts.py b/plugins/modules/oci_object_storage_namespace_metadata_facts.py index 50bc6bde0b..7df247df52 100644 --- a/plugins/modules/oci_object_storage_namespace_metadata_facts.py +++ b/plugins/modules/oci_object_storage_namespace_metadata_facts.py @@ -36,10 +36,7 @@ - The Object Storage namespace used for the request. type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_object.py b/plugins/modules/oci_object_storage_object.py index d0a5d9069d..d872f038d5 100644 --- a/plugins/modules/oci_object_storage_object.py +++ b/plugins/modules/oci_object_storage_object.py @@ -24,7 +24,8 @@ description: - This module allows the user to update and delete an Object resource in Oracle Cloud Infrastructure - "This resource has the following action operations in the M(oci_object_actions) module: copy, rename, restore." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: namespace_name: description: @@ -142,10 +143,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ @@ -265,30 +262,24 @@ def get_resource(self): object_name=self.module.params.get("object_name"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "namespace_name", "bucket_name", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_objects, **kwargs) def is_update(self): diff --git a/plugins/modules/oci_object_storage_object_actions.py b/plugins/modules/oci_object_storage_object_actions.py index 35e04dd599..50f7efba80 100644 --- a/plugins/modules/oci_object_storage_object_actions.py +++ b/plugins/modules/oci_object_storage_object_actions.py @@ -185,11 +185,11 @@ - The action to perform on the Object. type: str required: true - choices: ["copy", "rename", "restore"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "copy" + - "rename" + - "restore" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] """ diff --git a/plugins/modules/oci_object_storage_object_facts.py b/plugins/modules/oci_object_storage_object_facts.py index 00547408bf..505f460e98 100644 --- a/plugins/modules/oci_object_storage_object_facts.py +++ b/plugins/modules/oci_object_storage_object_facts.py @@ -101,10 +101,7 @@ Value of this parameter should be a comma-separated, case-insensitive list of those field names. For example 'name,etag,timeCreated,md5,timeModified' type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_object_lifecycle_policy.py b/plugins/modules/oci_object_storage_object_lifecycle_policy.py index c503be1027..8a0c86e139 100644 --- a/plugins/modules/oci_object_storage_object_lifecycle_policy.py +++ b/plugins/modules/oci_object_storage_object_lifecycle_policy.py @@ -23,7 +23,8 @@ short_description: Manage an ObjectLifecyclePolicy resource in Oracle Cloud Infrastructure description: - This module allows the user to update and delete an ObjectLifecyclePolicy resource in Oracle Cloud Infrastructure -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: namespace_name: description: @@ -134,10 +135,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_object_lifecycle_policy_facts.py b/plugins/modules/oci_object_storage_object_lifecycle_policy_facts.py index 650d34d3db..e7ae7d9c44 100644 --- a/plugins/modules/oci_object_storage_object_lifecycle_policy_facts.py +++ b/plugins/modules/oci_object_storage_object_lifecycle_policy_facts.py @@ -37,10 +37,7 @@ Example: `my-new-bucket1`" type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_object_version_facts.py b/plugins/modules/oci_object_storage_object_version_facts.py index edbe78e765..87949ded6c 100644 --- a/plugins/modules/oci_object_storage_object_version_facts.py +++ b/plugins/modules/oci_object_storage_object_version_facts.py @@ -68,10 +68,7 @@ Value of this parameter should be a comma-separated, case-insensitive list of those field names. For example 'name,etag,timeCreated,md5,timeModified' type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_object_storage_preauthenticated_request.py b/plugins/modules/oci_object_storage_preauthenticated_request.py index 41760e53e4..d6e1f882a5 100644 --- a/plugins/modules/oci_object_storage_preauthenticated_request.py +++ b/plugins/modules/oci_object_storage_preauthenticated_request.py @@ -24,7 +24,8 @@ description: - This module allows the user to create and delete a PreauthenticatedRequest resource in Oracle Cloud Infrastructure - For I(state=present), creates a pre-authenticated request specific to the bucket. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: namespace_name: description: @@ -80,10 +81,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -214,30 +211,24 @@ def get_resource(self): par_id=self.module.params.get("par_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "namespace_name", "bucket_name", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_preauthenticated_requests, **kwargs ) diff --git a/plugins/modules/oci_object_storage_preauthenticated_request_facts.py b/plugins/modules/oci_object_storage_preauthenticated_request_facts.py index adbf41615e..b4b9f9f1ee 100644 --- a/plugins/modules/oci_object_storage_preauthenticated_request_facts.py +++ b/plugins/modules/oci_object_storage_preauthenticated_request_facts.py @@ -49,10 +49,7 @@ description: - User-specified object name prefixes can be used to query and return a list of pre-authenticated requests. type: str -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_object_storage_replication_policy.py b/plugins/modules/oci_object_storage_replication_policy.py index 07def13358..1918931bb4 100644 --- a/plugins/modules/oci_object_storage_replication_policy.py +++ b/plugins/modules/oci_object_storage_replication_policy.py @@ -24,7 +24,8 @@ description: - This module allows the user to create and delete a ReplicationPolicy resource in Oracle Cloud Infrastructure - For I(state=present), creates a replication policy for the specified bucket. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: namespace_name: description: @@ -69,10 +70,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -209,30 +206,24 @@ def get_resource(self): replication_id=self.module.params.get("replication_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "namespace_name", "bucket_name", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_replication_policies, **kwargs ) diff --git a/plugins/modules/oci_object_storage_replication_policy_facts.py b/plugins/modules/oci_object_storage_replication_policy_facts.py index 9f82286e3a..2e65e78cff 100644 --- a/plugins/modules/oci_object_storage_replication_policy_facts.py +++ b/plugins/modules/oci_object_storage_replication_policy_facts.py @@ -44,10 +44,7 @@ - Required to get a specific replication_policy. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/plugins/modules/oci_object_storage_replication_source_facts.py b/plugins/modules/oci_object_storage_replication_source_facts.py index 5456131743..7659df3a4f 100644 --- a/plugins/modules/oci_object_storage_replication_source_facts.py +++ b/plugins/modules/oci_object_storage_replication_source_facts.py @@ -37,10 +37,7 @@ Example: `my-new-bucket1`" type: str required: true -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_object_storage_retention_rule.py b/plugins/modules/oci_object_storage_retention_rule.py index d538ba1a34..7838678a98 100644 --- a/plugins/modules/oci_object_storage_retention_rule.py +++ b/plugins/modules/oci_object_storage_retention_rule.py @@ -25,7 +25,8 @@ - This module allows the user to create, update and delete a RetentionRule resource in Oracle Cloud Infrastructure - For I(state=present), creates a new retention rule in the specified bucket. The new rule will take effect typically within 30 seconds. Note that a maximum of 100 rules are supported on a bucket. -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: namespace_name: description: @@ -86,10 +87,6 @@ required: false default: 'present' choices: ["present", "absent"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] """ @@ -251,30 +248,24 @@ def get_resource(self): retention_rule_id=self.module.params.get("retention_rule_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "namespace_name", "bucket_name", ] - optional_list_method_params = [] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( - (param, self.module.params[param]) - for param in optional_list_method_params - if self.module.params.get(param) is not None - and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") - ) - ) + def get_optional_kwargs_for_list(self): + return dict() - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources( self.client.list_retention_rules, **kwargs ) diff --git a/plugins/modules/oci_object_storage_retention_rule_facts.py b/plugins/modules/oci_object_storage_retention_rule_facts.py index 6870bb3ae6..0d99b35055 100644 --- a/plugins/modules/oci_object_storage_retention_rule_facts.py +++ b/plugins/modules/oci_object_storage_retention_rule_facts.py @@ -45,10 +45,7 @@ - Required to get a specific retention_rule. type: str aliases: ["id"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_display_name_option ] """ diff --git a/plugins/modules/oci_ons_notification_topic.py b/plugins/modules/oci_ons_notification_topic.py new file mode 100644 index 0000000000..d938855dba --- /dev/null +++ b/plugins/modules/oci_ons_notification_topic.py @@ -0,0 +1,372 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_ons_notification_topic +short_description: Manage a NotificationTopic resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a NotificationTopic resource in Oracle Cloud Infrastructure + - For I(state=present), creates a topic in the specified compartment. For general information about topics, see + L(Managing Topics and Subscriptions,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm). + - For the purposes of access control, you must provide the OCID of the compartment where you want the topic to reside. + For information about access control and compartments, see L(Overview of the IAM + Service,https://docs.cloud.oracle.com/Content/Identity/Concepts/overview.htm). + - You must specify a display name for the topic. + - All Oracle Cloud Infrastructure resources, including topics, get an Oracle-assigned, unique ID called an + Oracle Cloud Identifier (OCID). When you create a resource, you can find its OCID in the response. You can also + retrieve a resource's OCID by using a List API operation on that resource type, or by viewing the resource in the + Console. For more information, see L(Resource Identifiers,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm). + - "Transactions Per Minute (TPM) per-tenancy limit for this operation: 60." +version_added: "2.9" +author: Oracle (@oracle) +options: + name: + description: + - The name of the topic being created. The topic name must be unique across the tenancy. Avoid entering confidential information. + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment to create the topic in. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + description: + description: + - The description of the topic being created. Avoid entering confidential information. + - Required for update using I(state=present) with topic_id present. + type: str + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see + L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the topic to update. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the NotificationTopic. + - Use I(state=present) to create or update a NotificationTopic. + - Use I(state=absent) to delete a NotificationTopic. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource ] +""" + +EXAMPLES = """ +- name: Create notification_topic + oci_ons_notification_topic: + name: Admins + compartment_id: compartment_OCID + description: Channel for admin messages + +- name: Update notification_topic using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_ons_notification_topic: + description: Channel for admin messages + +- name: Update notification_topic + oci_ons_notification_topic: + description: Channel for admin messages + topic_id: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete notification_topic + oci_ons_notification_topic: + topic_id: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete notification_topic using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_ons_notification_topic: + name: Admins + compartment_id: compartment_OCID + state: absent + +""" + +RETURN = """ +notification_topic: + description: + - Details of the NotificationTopic resource acted upon by the current operation + returned: on success + type: complex + contains: + name: + description: + - The name of the topic. + returned: on success + type: string + sample: name_example + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the topic. + returned: on success + type: string + sample: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment for the topic. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + lifecycle_state: + description: + - The lifecycle state of the topic. + returned: on success + type: string + sample: ACTIVE + description: + description: + - The description of the topic. + returned: on success + type: string + sample: description_example + time_created: + description: + - The time the topic was created. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + etag: + description: + - For optimistic concurrency control. See `if-match`. + returned: on success + type: string + sample: etag_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see + L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + api_endpoint: + description: + - The endpoint for managing subscriptions or publishing messages to the topic. + returned: on success + type: string + sample: api_endpoint_example + sample: { + "name": "name_example", + "topic_id": "ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "lifecycle_state": "ACTIVE", + "description": "description_example", + "time_created": "2013-10-20T19:20:30+01:00", + "etag": "etag_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "api_endpoint": "api_endpoint_example" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.ons import NotificationControlPlaneClient + from oci.ons.models import CreateTopicDetails + from oci.ons.models import TopicAttributesDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class NotificationTopicHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "topic_id" + + def get_module_resource_id(self): + return self.module.params.get("topic_id") + + def get_get_fn(self): + return self.client.get_topic + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_topic, topic_id=self.module.params.get("topic_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["name"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_topics, **kwargs) + + def get_create_model_class(self): + return CreateTopicDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_topic, + call_fn_args=(), + call_fn_kwargs=dict(create_topic_details=create_details,), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return TopicAttributesDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_topic, + call_fn_args=(), + call_fn_kwargs=dict( + topic_id=self.module.params.get("topic_id"), + topic_attributes_details=update_details, + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_topic, + call_fn_args=(), + call_fn_kwargs=dict(topic_id=self.module.params.get("topic_id"),), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +NotificationTopicHelperCustom = get_custom_class("NotificationTopicHelperCustom") + + +class ResourceHelper(NotificationTopicHelperCustom, NotificationTopicHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=False + ) + module_args.update( + dict( + name=dict(type="str"), + compartment_id=dict(type="str"), + description=dict(type="str"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + topic_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="notification_topic", + service_client_class=NotificationControlPlaneClient, + namespace="ons", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_ons_notification_topic_facts.py b/plugins/modules/oci_ons_notification_topic_facts.py new file mode 100644 index 0000000000..42941910a1 --- /dev/null +++ b/plugins/modules/oci_ons_notification_topic_facts.py @@ -0,0 +1,273 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_ons_notification_topic_facts +short_description: Fetches details about one or multiple NotificationTopic resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple NotificationTopic resources in Oracle Cloud Infrastructure + - Lists topics in the specified compartment. + - "Transactions Per Minute (TPM) per-tenancy limit for this operation: 120." + - If I(topic_id) is specified, the details of a single NotificationTopic will be returned. +version_added: "2.5" +options: + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the topic to retrieve. + - "Transactions Per Minute (TPM) per-tenancy limit for this operation: 120." + - Required to get a specific notification_topic. + type: str + aliases: ["id"] + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment. + - Required to list multiple notification_topics. + type: str + name: + description: + - A filter to only return resources that match the given name exactly. + type: str + sort_by: + description: + - The field to sort by. Only one field can be selected for sorting. + type: str + choices: + - "TIMECREATED" + - "LIFECYCLESTATE" + sort_order: + description: + - The sort order to use (ascending or descending). + type: str + choices: + - "ASC" + - "DESC" + lifecycle_state: + description: + - Filter returned list by specified lifecycle state. This parameter is case-insensitive. + type: str + choices: + - "ACTIVE" + - "DELETING" + - "CREATING" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List notification_topics + oci_ons_notification_topic_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific notification_topic + oci_ons_notification_topic_facts: + topic_id: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +notification_topics: + description: + - List of NotificationTopic resources + returned: on success + type: complex + contains: + name: + description: + - The name of the topic. + returned: on success + type: string + sample: name_example + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the topic. + returned: on success + type: string + sample: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment for the topic. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + lifecycle_state: + description: + - The lifecycle state of the topic. + returned: on success + type: string + sample: ACTIVE + description: + description: + - The description of the topic. + returned: on success + type: string + sample: description_example + time_created: + description: + - The time the topic was created. + returned: on success + type: string + sample: 2013-10-20T19:20:30+01:00 + etag: + description: + - For optimistic concurrency control. See `if-match`. + returned: on success + type: string + sample: etag_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see + L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + api_endpoint: + description: + - The endpoint for managing subscriptions or publishing messages to the topic. + returned: on success + type: string + sample: api_endpoint_example + sample: [{ + "name": "name_example", + "topic_id": "ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "lifecycle_state": "ACTIVE", + "description": "description_example", + "time_created": "2013-10-20T19:20:30+01:00", + "etag": "etag_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "api_endpoint": "api_endpoint_example" + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.ons import NotificationControlPlaneClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class NotificationTopicFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "topic_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_topic, topic_id=self.module.params.get("topic_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "id", + "name", + "sort_by", + "sort_order", + "lifecycle_state", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_topics, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +NotificationTopicFactsHelperCustom = get_custom_class( + "NotificationTopicFactsHelperCustom" +) + + +class ResourceFactsHelper( + NotificationTopicFactsHelperCustom, NotificationTopicFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + topic_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + name=dict(type="str"), + sort_by=dict(type="str", choices=["TIMECREATED", "LIFECYCLESTATE"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + lifecycle_state=dict( + type="str", choices=["ACTIVE", "DELETING", "CREATING"] + ), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="notification_topic", + service_client_class=NotificationControlPlaneClient, + namespace="ons", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(notification_topics=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_ons_subscription.py b/plugins/modules/oci_ons_subscription.py new file mode 100644 index 0000000000..519d97c1d9 --- /dev/null +++ b/plugins/modules/oci_ons_subscription.py @@ -0,0 +1,428 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_ons_subscription +short_description: Manage a Subscription resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a Subscription resource in Oracle Cloud Infrastructure + - "For I(state=present), creates a subscription for the specified topic and sends a subscription confirmation URL to the endpoint. The subscription remains + in \\"Pending\\" status until it has been confirmed. + For information about confirming subscriptions, see + L(To confirm a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#confirmSub)." + - "Transactions Per Minute (TPM) per-tenancy limit for this operation: 60." + - "This resource has the following action operations in the M(oci_subscription_actions) module: get_unsubscription, resend_subscription_confirmation." +version_added: "2.9" +author: Oracle (@oracle) +options: + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the topic for the subscription. + - Required for create using I(state=present). + type: str + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment for the subscription. + - Required for create using I(state=present). + type: str + protocol: + description: + - The protocol used for the subscription. + - "Allowed values: + * `CUSTOM_HTTPS` + * `EMAIL` + * `HTTPS` (deprecated; for PagerDuty endpoints, use `PAGERDUTY`) + * `PAGERDUTY` + * `SLACK`" + - For information about subscription protocols, see + L(To create a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createSub). + - Required for create using I(state=present). + type: str + endpoint: + description: + - "A locator that corresponds to the subscription protocol. + For example, an email address for a subscription that uses the `EMAIL` protocol, or a URL for a subscription that uses an HTTP-based protocol. + HTTP-based protocols use URL endpoints that begin with \\"http:\\" or \\"https:\\". + A URL cannot exceed 512 characters. + Avoid entering confidential information." + - For protocol-specific endpoint formats and steps to get or create endpoints, see + L(To create a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createSub). + - Required for create using I(state=present). + type: str + metadata: + description: + - Metadata for the subscription. + type: str + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see + L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + subscription_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription to update. + - Required for update using I(state=present). + - Required for delete using I(state=absent). + type: str + aliases: ["id"] + delivery_policy: + description: + - The delivery policy of the subscription. Stored as a JSON string. + type: dict + suboptions: + backoff_retry_policy: + description: + - "" + type: dict + suboptions: + max_retry_duration: + description: + - The maximum retry duration in milliseconds. Default value is `7200000` (2 hours). + type: int + required: true + policy_type: + description: + - The type of delivery policy. + type: str + choices: + - "EXPONENTIAL" + required: true + state: + description: + - The state of the Subscription. + - Use I(state=present) to create or update a Subscription. + - Use I(state=absent) to delete a Subscription. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create subscription + oci_ons_subscription: + topic_id: topic_OCID + compartment_id: compartment_OCID + protocol: EMAIL + endpoint: john.smith@example.com + +- name: Update subscription + oci_ons_subscription: + freeform_tags: '{''Department'': ''Finance''}' + subscription_id: ocid1.subscription.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete subscription + oci_ons_subscription: + subscription_id: ocid1.subscription.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +""" + +RETURN = """ +subscription: + description: + - Details of the Subscription resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the associated topic. + returned: on success + type: string + sample: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + protocol: + description: + - The protocol used for the subscription. + For information about subscription protocols, see + L(To create a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createSub). + returned: on success + type: string + sample: EMAIL + endpoint: + description: + - A locator that corresponds to the subscription protocol. + For example, an email address for a subscription that uses the `EMAIL` protocol, or a URL for a subscription that uses an HTTP-based protocol. + returned: on success + type: string + sample: endpoint_example + lifecycle_state: + description: + - The lifecycle state of the subscription. The status of a new subscription is PENDING; when confirmed, the subscription status changes to + ACTIVE. + returned: on success + type: string + sample: PENDING + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment for the subscription. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + created_time: + description: + - The time when this suscription was created. + returned: on success + type: int + sample: 56 + deliver_policy: + description: + - The delivery policy of the subscription. Stored as a JSON string. + returned: on success + type: string + sample: deliver_policy_example + etag: + description: + - For optimistic concurrency control. See `if-match`. + returned: on success + type: string + sample: etag_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see + L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "topic_id": "ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx", + "protocol": "EMAIL", + "endpoint": "endpoint_example", + "lifecycle_state": "PENDING", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "created_time": 56, + "deliver_policy": "deliver_policy_example", + "etag": "etag_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.ons import NotificationDataPlaneClient + from oci.ons.models import CreateSubscriptionDetails + from oci.ons.models import UpdateSubscriptionDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SubscriptionHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "subscription_id" + + def get_module_resource_id(self): + return self.module.params.get("subscription_id") + + def get_get_fn(self): + return self.client.get_subscription + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_subscription, + subscription_id=self.module.params.get("subscription_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["topic_id"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_subscriptions, **kwargs + ) + + def get_create_model_class(self): + return CreateSubscriptionDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_subscription, + call_fn_args=(), + call_fn_kwargs=dict(create_subscription_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateSubscriptionDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_subscription, + call_fn_args=(), + call_fn_kwargs=dict( + subscription_id=self.module.params.get("subscription_id"), + update_subscription_details=update_details, + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_subscription, + call_fn_args=(), + call_fn_kwargs=dict( + subscription_id=self.module.params.get("subscription_id"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +SubscriptionHelperCustom = get_custom_class("SubscriptionHelperCustom") + + +class ResourceHelper(SubscriptionHelperCustom, SubscriptionHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + topic_id=dict(type="str"), + compartment_id=dict(type="str"), + protocol=dict(type="str"), + endpoint=dict(type="str"), + metadata=dict(type="str"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + subscription_id=dict(aliases=["id"], type="str"), + delivery_policy=dict( + type="dict", + options=dict( + backoff_retry_policy=dict( + type="dict", + options=dict( + max_retry_duration=dict(type="int", required=True), + policy_type=dict( + type="str", required=True, choices=["EXPONENTIAL"] + ), + ), + ) + ), + ), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="subscription", + service_client_class=NotificationDataPlaneClient, + namespace="ons", + ) + + result = dict(changed=False) + + if resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_ons_subscription_actions.py b/plugins/modules/oci_ons_subscription_actions.py new file mode 100644 index 0000000000..6b67c66472 --- /dev/null +++ b/plugins/modules/oci_ons_subscription_actions.py @@ -0,0 +1,300 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_ons_subscription_actions +short_description: Perform actions on a Subscription resource in Oracle Cloud Infrastructure +description: + - Perform actions on a Subscription resource in Oracle Cloud Infrastructure + - "For I(action=get_unsubscription), gets the unsubscription details for the specified subscription. + Transactions Per Minute (TPM) per-tenancy limit for this operation: 60." + - "For I(action=resend_subscription_confirmation), resends the confirmation details for the specified subscription. + Transactions Per Minute (TPM) per-tenancy limit for this operation: 60." +version_added: "2.5" +options: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription to unsubscribe from. + type: str + required: true + token: + description: + - The subscription confirmation token. + - Required for I(action=get_unsubscription). + type: str + protocol: + description: + - The protocol used for the subscription. + - "Allowed values: + * `CUSTOM_HTTPS` + * `EMAIL` + * `HTTPS` (deprecated; for PagerDuty endpoints, use `PAGERDUTY`) + * `PAGERDUTY` + * `SLACK`" + - For information about subscription protocols, see + L(To create a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createSub). + - Required for I(action=get_unsubscription). + type: str + action: + description: + - The action to perform on the Subscription. + type: str + required: true + choices: + - "get_unsubscription" + - "resend_subscription_confirmation" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Perform action get_unsubscription on subscription + oci_ons_subscription_actions: + id: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + token: token_example + protocol: protocol_example + action: get_unsubscription + +- name: Perform action resend_subscription_confirmation on subscription + oci_ons_subscription_actions: + id: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + action: resend_subscription_confirmation + +""" + +RETURN = """ +subscription: + description: + - Details of the Subscription resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the associated topic. + returned: on success + type: string + sample: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + protocol: + description: + - The protocol used for the subscription. + For information about subscription protocols, see + L(To create a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createSub). + returned: on success + type: string + sample: EMAIL + endpoint: + description: + - A locator that corresponds to the subscription protocol. + For example, an email address for a subscription that uses the `EMAIL` protocol, or a URL for a subscription that uses an HTTP-based protocol. + returned: on success + type: string + sample: endpoint_example + lifecycle_state: + description: + - The lifecycle state of the subscription. The status of a new subscription is PENDING; when confirmed, the subscription status changes to + ACTIVE. + returned: on success + type: string + sample: PENDING + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment for the subscription. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + created_time: + description: + - The time when this suscription was created. + returned: on success + type: int + sample: 56 + deliver_policy: + description: + - The delivery policy of the subscription. Stored as a JSON string. + returned: on success + type: string + sample: deliver_policy_example + etag: + description: + - For optimistic concurrency control. See `if-match`. + returned: on success + type: string + sample: etag_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see + L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: { + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "topic_id": "ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx", + "protocol": "EMAIL", + "endpoint": "endpoint_example", + "lifecycle_state": "PENDING", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "created_time": 56, + "deliver_policy": "deliver_policy_example", + "etag": "etag_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIActionsHelperBase, + get_custom_class, +) + +try: + from oci.ons import NotificationDataPlaneClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SubscriptionActionsHelperGen(OCIActionsHelperBase): + """ + Supported actions: + get_unsubscription + resend_subscription_confirmation + """ + + @staticmethod + def get_module_resource_id_param(): + return "id" + + def get_module_resource_id(self): + return self.module.params.get("id") + + def get_get_fn(self): + return self.client.get_subscription + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_subscription, + subscription_id=self.module.params.get("subscription_id"), + ) + + def get_unsubscription(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.get_unsubscription, + call_fn_args=(), + call_fn_kwargs=dict( + id=self.module.params.get("id"), + token=self.module.params.get("token"), + protocol=self.module.params.get("protocol"), + ), + waiter_type=oci_wait_utils.NONE_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_action_desired_states( + self.module.params.get("action") + ), + ) + + def resend_subscription_confirmation(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.resend_subscription_confirmation, + call_fn_args=(), + call_fn_kwargs=dict(id=self.module.params.get("id"),), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation="{0}_{1}".format( + self.module.params.get("action").upper(), + oci_common_utils.ACTION_OPERATION_KEY, + ), + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_action_desired_states( + self.module.params.get("action") + ), + ) + + +SubscriptionActionsHelperCustom = get_custom_class("SubscriptionActionsHelperCustom") + + +class ResourceHelper(SubscriptionActionsHelperCustom, SubscriptionActionsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=False, supports_wait=True + ) + module_args.update( + dict( + id=dict(type="str", required=True), + token=dict(type="str"), + protocol=dict(type="str"), + action=dict( + type="str", + required=True, + choices=["get_unsubscription", "resend_subscription_confirmation"], + ), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="subscription", + service_client_class=NotificationDataPlaneClient, + namespace="ons", + ) + + result = resource_helper.perform_action(module.params.get("action")) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_ons_subscription_confirmation_facts.py b/plugins/modules/oci_ons_subscription_confirmation_facts.py new file mode 100644 index 0000000000..60860b32f3 --- /dev/null +++ b/plugins/modules/oci_ons_subscription_confirmation_facts.py @@ -0,0 +1,201 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_ons_subscription_confirmation_facts +short_description: Fetches details about a SubscriptionConfirmation resource in Oracle Cloud Infrastructure +description: + - Fetches details about a SubscriptionConfirmation resource in Oracle Cloud Infrastructure + - Gets the confirmation details for the specified subscription. + - "Transactions Per Minute (TPM) per-tenancy limit for this operation: 60." +version_added: "2.5" +options: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription to get the confirmation details for. + type: str + required: true + token: + description: + - The subscription confirmation token. + type: str + required: true + protocol: + description: + - The protocol used for the subscription. + - "Allowed values: + * `CUSTOM_HTTPS` + * `EMAIL` + * `HTTPS` (deprecated; for PagerDuty endpoints, use `PAGERDUTY`) + * `PAGERDUTY` + * `SLACK`" + - For information about subscription protocols, see + L(To create a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createSub). + type: str + required: true +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: Get a specific subscription_confirmation + oci_ons_subscription_confirmation_facts: + id: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + token: token_example + protocol: protocol_example + +""" + +RETURN = """ +subscription_confirmation: + description: + - SubscriptionConfirmation resource + returned: on success + type: complex + contains: + topic_name: + description: + - The name of the subscribed topic. + returned: on success + type: string + sample: topic_name_example + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the topic associated with the specified + subscription. + returned: on success + type: string + sample: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + endpoint: + description: + - A locator that corresponds to the subscription protocol. + For example, an email address for a subscription that uses the `EMAIL` protocol, or a URL for a subscription that uses an HTTP-based protocol. + returned: on success + type: string + sample: abc@oracle.com + unsubscribe_url: + description: + - The URL for unsubscribing from the topic. + returned: on success + type: string + sample: unsubscribe_url_example + message: + description: + - A human-readable string indicating the status of the subscription confirmation. + returned: on success + type: string + sample: The subscription has been confirmed + subscription_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription specified in the request. + returned: on success + type: string + sample: ocid1.subscription.oc1..xxxxxxEXAMPLExxxxxx + sample: { + "topic_name": "topic_name_example", + "topic_id": "ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx", + "endpoint": "abc@oracle.com", + "unsubscribe_url": "unsubscribe_url_example", + "message": "The subscription has been confirmed", + "subscription_id": "ocid1.subscription.oc1..xxxxxxEXAMPLExxxxxx" + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.ons import NotificationDataPlaneClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SubscriptionConfirmationFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get""" + + def get_required_params_for_get(self): + return [ + "id", + "token", + "protocol", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_confirm_subscription, + id=self.module.params.get("id"), + token=self.module.params.get("token"), + protocol=self.module.params.get("protocol"), + ) + + +SubscriptionConfirmationFactsHelperCustom = get_custom_class( + "SubscriptionConfirmationFactsHelperCustom" +) + + +class ResourceFactsHelper( + SubscriptionConfirmationFactsHelperCustom, SubscriptionConfirmationFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + id=dict(type="str", required=True), + token=dict(type="str", required=True), + protocol=dict(type="str", required=True), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="subscription_confirmation", + service_client_class=NotificationDataPlaneClient, + namespace="ons", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = resource_facts_helper.get() + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(subscription_confirmation=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_ons_subscription_facts.py b/plugins/modules/oci_ons_subscription_facts.py new file mode 100644 index 0000000000..7840e3c3e4 --- /dev/null +++ b/plugins/modules/oci_ons_subscription_facts.py @@ -0,0 +1,280 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_ons_subscription_facts +short_description: Fetches details about one or multiple Subscription resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Subscription resources in Oracle Cloud Infrastructure + - Lists the subscriptions in the specified compartment or topic. + - "Transactions Per Minute (TPM) per-tenancy limit for this operation: 60." + - If I(subscription_id) is specified, the details of a single Subscription will be returned. +version_added: "2.5" +options: + subscription_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription to retrieve. + - Required to get a specific subscription. + type: str + aliases: ["id"] + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment. + - Required to list multiple subscriptions. + type: str + topic_id: + description: + - Return all subscriptions that are subscribed to the given topic OCID. Either this query parameter or the compartmentId query parameter must be + set. + type: str +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List subscriptions + oci_ons_subscription_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific subscription + oci_ons_subscription_facts: + subscription_id: ocid1.subscription.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +subscriptions: + description: + - List of Subscription resources + returned: on success + type: complex + contains: + id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the subscription. + returned: on success + type: string + sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx + topic_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the associated topic. + returned: on success + type: string + sample: ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx + protocol: + description: + - The protocol used for the subscription. + For information about subscription protocols, see + L(To create a subscription,https://docs.cloud.oracle.com/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createSub). + returned: on success + type: string + sample: EMAIL + endpoint: + description: + - A locator that corresponds to the subscription protocol. + For example, an email address for a subscription that uses the `EMAIL` protocol, or a URL for a subscription that uses an HTTP-based protocol. + returned: on success + type: string + sample: endpoint_example + lifecycle_state: + description: + - The lifecycle state of the subscription. The status of a new subscription is PENDING; when confirmed, the subscription status changes to + ACTIVE. + returned: on success + type: string + sample: PENDING + compartment_id: + description: + - The L(OCID,https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment for the subscription. + returned: on success + type: string + sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + created_time: + description: + - The time when this suscription was created. + returned: on success + type: int + sample: 56 + deliver_policy: + description: + - The delivery policy of the subscription. Stored as a JSON string. + returned: on success + type: string + sample: deliver_policy_example + etag: + description: + - For optimistic concurrency control. See `if-match`. + returned: on success + type: string + sample: etag_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see + L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + delivery_policy: + description: + - "" + returned: on success + type: complex + contains: + backoff_retry_policy: + description: + - "" + returned: on success + type: complex + contains: + max_retry_duration: + description: + - The maximum retry duration in milliseconds. Default value is `7200000` (2 hours). + returned: on success + type: int + sample: 56 + policy_type: + description: + - The type of delivery policy. + returned: on success + type: string + sample: EXPONENTIAL + sample: [{ + "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx", + "topic_id": "ocid1.topic.oc1..xxxxxxEXAMPLExxxxxx", + "protocol": "EMAIL", + "endpoint": "endpoint_example", + "lifecycle_state": "PENDING", + "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx", + "created_time": 56, + "deliver_policy": "deliver_policy_example", + "etag": "etag_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}}, + "delivery_policy": { + "backoff_retry_policy": { + "max_retry_duration": 56, + "policy_type": "EXPONENTIAL" + } + } + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.ons import NotificationDataPlaneClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class SubscriptionFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "subscription_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_subscription, + subscription_id=self.module.params.get("subscription_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "topic_id", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_subscriptions, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +SubscriptionFactsHelperCustom = get_custom_class("SubscriptionFactsHelperCustom") + + +class ResourceFactsHelper(SubscriptionFactsHelperCustom, SubscriptionFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + subscription_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + topic_id=dict(type="str"), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="subscription", + service_client_class=NotificationDataPlaneClient, + namespace="ons", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(subscriptions=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_secrets_secret_bundle_facts.py b/plugins/modules/oci_secrets_secret_bundle_facts.py index f1baf74400..dd0a8aa34d 100644 --- a/plugins/modules/oci_secrets_secret_bundle_facts.py +++ b/plugins/modules/oci_secrets_secret_bundle_facts.py @@ -51,10 +51,7 @@ - "LATEST" - "PREVIOUS" - "DEPRECATED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_secrets_secret_bundle_version_facts.py b/plugins/modules/oci_secrets_secret_bundle_version_facts.py index ae919c0055..d6e2c58329 100644 --- a/plugins/modules/oci_secrets_secret_bundle_version_facts.py +++ b/plugins/modules/oci_secrets_secret_bundle_version_facts.py @@ -45,10 +45,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_streaming_connect_harness.py b/plugins/modules/oci_streaming_connect_harness.py new file mode 100644 index 0000000000..d33b6c790b --- /dev/null +++ b/plugins/modules/oci_streaming_connect_harness.py @@ -0,0 +1,356 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_streaming_connect_harness +short_description: Manage a ConnectHarness resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a ConnectHarness resource in Oracle Cloud Infrastructure + - For I(state=present), starts the provisioning of a new connect harness. + To track the progress of the provisioning, you can periodically call L(GetConnectHarness]. + In the response, the `lifecycleState` parameter of the [ConnectHarness,https://docs.cloud.oracle.com/#/en/streaming/20180418/ConnectHarness/) object tells + you its current state. +version_added: "2.9" +author: Oracle (@oracle) +options: + name: + description: + - The name of the connect harness. Avoid entering confidential information. + - "Example: `JDBCConnector`" + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + compartment_id: + description: + - The OCID of the compartment that contains the connect harness. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair that is applied with no predefined name, type, or namespace. Exists for + cross-compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + connect_harness_id: + description: + - The OCID of the connect harness. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the ConnectHarness. + - Use I(state=present) to create or update a ConnectHarness. + - Use I(state=absent) to delete a ConnectHarness. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create connect_harness + oci_streaming_connect_harness: + compartment_id: ocid1.tenancy.oc1..exampleasgadvsw7l6cvb4fhssurjqs4irbkzma3wc2fauxv4novazj5guta + name: mynewconnectharness + +- name: Update connect_harness using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_streaming_connect_harness: + name: mynewconnectharness + compartment_id: ocid1.tenancy.oc1..exampleasgadvsw7l6cvb4fhssurjqs4irbkzma3wc2fauxv4novazj5guta + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + +- name: Update connect_harness + oci_streaming_connect_harness: + connect_harness_id: ocid1.connectharness.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete connect_harness + oci_streaming_connect_harness: + connect_harness_id: ocid1.connectharness.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete connect_harness using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_streaming_connect_harness: + name: mynewconnectharness + compartment_id: ocid1.tenancy.oc1..exampleasgadvsw7l6cvb4fhssurjqs4irbkzma3wc2fauxv4novazj5guta + state: absent + +""" + +RETURN = """ +connect_harness: + description: + - Details of the ConnectHarness resource acted upon by the current operation + returned: on success + type: complex + contains: + name: + description: + - The name of the connect harness. Avoid entering confidential information. + - "Example: `JDBCConnector`" + returned: on success + type: string + sample: TelemetryEvents + id: + description: + - The OCID of the connect harness. + returned: on success + type: string + sample: ocid1.connectharness.realm.region.mnopqr789 + compartment_id: + description: + - The OCID of the compartment that contains the connect harness. + returned: on success + type: string + sample: ocid1.compartment.realm.region.zxcvbn432765 + lifecycle_state: + description: + - The current state of the connect harness. + returned: on success + type: string + sample: CREATING + lifecycle_state_details: + description: + - Any additional details about the current state of the connect harness. + returned: on success + type: string + sample: lifecycle_state_details_example + time_created: + description: + - The date and time the connect harness was created, expressed in in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339) timestamp format. + - "Example: `2018-04-20T00:00:07.405Z`" + returned: on success + type: string + sample: 2018-04-20T00:00:07.405Z + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross- + compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}'" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: { + "name": "TelemetryEvents", + "id": "ocid1.connectharness.realm.region.mnopqr789", + "compartment_id": "ocid1.compartment.realm.region.zxcvbn432765", + "lifecycle_state": "CREATING", + "lifecycle_state_details": "lifecycle_state_details_example", + "time_created": "2018-04-20T00:00:07.405Z", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.streaming import StreamAdminClient + from oci.streaming.models import CreateConnectHarnessDetails + from oci.streaming.models import UpdateConnectHarnessDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ConnectHarnessHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "connect_harness_id" + + def get_module_resource_id(self): + return self.module.params.get("connect_harness_id") + + def get_get_fn(self): + return self.client.get_connect_harness + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_connect_harness, + connect_harness_id=self.module.params.get("connect_harness_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["name"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_connect_harnesses, **kwargs + ) + + def get_create_model_class(self): + return CreateConnectHarnessDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_connect_harness, + call_fn_args=(), + call_fn_kwargs=dict(create_connect_harness_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateConnectHarnessDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_connect_harness, + call_fn_args=(), + call_fn_kwargs=dict( + connect_harness_id=self.module.params.get("connect_harness_id"), + update_connect_harness_details=update_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_connect_harness, + call_fn_args=(), + call_fn_kwargs=dict( + connect_harness_id=self.module.params.get("connect_harness_id"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +ConnectHarnessHelperCustom = get_custom_class("ConnectHarnessHelperCustom") + + +class ResourceHelper(ConnectHarnessHelperCustom, ConnectHarnessHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + name=dict(type="str"), + compartment_id=dict(type="str"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + connect_harness_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="connect_harness", + service_client_class=StreamAdminClient, + namespace="streaming", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_streaming_connect_harness_facts.py b/plugins/modules/oci_streaming_connect_harness_facts.py new file mode 100644 index 0000000000..1cf08d0cfc --- /dev/null +++ b/plugins/modules/oci_streaming_connect_harness_facts.py @@ -0,0 +1,276 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_streaming_connect_harness_facts +short_description: Fetches details about one or multiple ConnectHarness resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple ConnectHarness resources in Oracle Cloud Infrastructure + - Lists the connectharness. + - If I(connect_harness_id) is specified, the details of a single ConnectHarness will be returned. +version_added: "2.5" +options: + connect_harness_id: + description: + - The OCID of the connect harness. + - Required to get a specific connect_harness. + type: str + aliases: ["id"] + compartment_id: + description: + - The OCID of the compartment. + - Required to list multiple connect_harness. + type: str + id: + description: + - A filter to return only resources that match the given ID exactly. + type: str + name: + description: + - A filter to return only resources that match the given name exactly. + type: str + sort_by: + description: + - The field to sort by. You can provide no more than one sort order. By default, `TIMECREATED` sorts results in descending order and `NAME` sorts + results in ascending order. + type: str + choices: + - "NAME" + - "TIMECREATED" + sort_order: + description: + - The sort order to use, either 'asc' or 'desc'. + type: str + choices: + - "ASC" + - "DESC" + lifecycle_state: + description: + - A filter to only return resources that match the given lifecycle state. The state value is case-insensitive. + type: str + choices: + - "CREATING" + - "ACTIVE" + - "DELETING" + - "DELETED" + - "FAILED" + - "UPDATING" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List connect_harness + oci_streaming_connect_harness_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific connect_harness + oci_streaming_connect_harness_facts: + connect_harness_id: ocid1.connectharness.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +connect_harness: + description: + - List of ConnectHarness resources + returned: on success + type: complex + contains: + name: + description: + - The name of the connect harness. Avoid entering confidential information. + - "Example: `JDBCConnector`" + returned: on success + type: string + sample: TelemetryEvents + id: + description: + - The OCID of the connect harness. + returned: on success + type: string + sample: ocid1.connectharness.realm.region.mnopqr789 + compartment_id: + description: + - The OCID of the compartment that contains the connect harness. + returned: on success + type: string + sample: ocid1.compartment.realm.region.zxcvbn432765 + lifecycle_state: + description: + - The current state of the connect harness. + returned: on success + type: string + sample: CREATING + lifecycle_state_details: + description: + - Any additional details about the current state of the connect harness. + returned: on success + type: string + sample: lifecycle_state_details_example + time_created: + description: + - The date and time the connect harness was created, expressed in in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339) timestamp format. + - "Example: `2018-04-20T00:00:07.405Z`" + returned: on success + type: string + sample: 2018-04-20T00:00:07.405Z + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross- + compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}'" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: [{ + "name": "TelemetryEvents", + "id": "ocid1.connectharness.realm.region.mnopqr789", + "compartment_id": "ocid1.compartment.realm.region.zxcvbn432765", + "lifecycle_state": "CREATING", + "lifecycle_state_details": "lifecycle_state_details_example", + "time_created": "2018-04-20T00:00:07.405Z", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.streaming import StreamAdminClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class ConnectHarnessFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "connect_harness_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_connect_harness, + connect_harness_id=self.module.params.get("connect_harness_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "id", + "name", + "sort_by", + "sort_order", + "lifecycle_state", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_connect_harnesses, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +ConnectHarnessFactsHelperCustom = get_custom_class("ConnectHarnessFactsHelperCustom") + + +class ResourceFactsHelper( + ConnectHarnessFactsHelperCustom, ConnectHarnessFactsHelperGen +): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + connect_harness_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + id=dict(type="str"), + name=dict(type="str"), + sort_by=dict(type="str", choices=["NAME", "TIMECREATED"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + lifecycle_state=dict( + type="str", + choices=[ + "CREATING", + "ACTIVE", + "DELETING", + "DELETED", + "FAILED", + "UPDATING", + ], + ), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="connect_harness", + service_client_class=StreamAdminClient, + namespace="streaming", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(connect_harness=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_streaming_stream.py b/plugins/modules/oci_streaming_stream.py new file mode 100644 index 0000000000..fa19ca8fe9 --- /dev/null +++ b/plugins/modules/oci_streaming_stream.py @@ -0,0 +1,395 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_streaming_stream +short_description: Manage a Stream resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a Stream resource in Oracle Cloud Infrastructure + - For I(state=present), starts the provisioning of a new stream. + The stream will be created in the given compartment id or stream pool id, depending on which parameter is specified. + Compartment id and stream pool id cannot be specified at the same time. + To track the progress of the provisioning, you can periodically call L(GetStream,https://docs.cloud.oracle.com/#/en/streaming/20180418/Stream/GetStream). + In the response, the `lifecycleState` parameter of the L(Stream,https://docs.cloud.oracle.com/#/en/streaming/20180418/Stream/) object tells you its + current state. +version_added: "2.9" +author: Oracle (@oracle) +options: + name: + description: + - The name of the stream. Avoid entering confidential information. + - "Example: `TelemetryEvents`" + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + partitions: + description: + - The number of partitions in the stream. + - Required for create using I(state=present). + type: int + compartment_id: + description: + - The OCID of the compartment that contains the stream. + type: str + stream_pool_id: + description: + - The OCID of the stream pool that contains the stream. + type: str + retention_in_hours: + description: + - The retention period of the stream, in hours. Accepted values are between 24 and 168 (7 days). + If not specified, the stream will have a retention period of 24 hours. + type: int + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair that is applied with no predefined name, type, or namespace. Exists for + cross-compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + stream_id: + description: + - The OCID of the stream. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the Stream. + - Use I(state=present) to create or update a Stream. + - Use I(state=absent) to delete a Stream. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create stream + oci_streaming_stream: + compartment_id: ocid1.tenancy.oc1..exampleasgadvsw7l6cvb4fhssurjqs4irbkzma3wc2fauxv4novazj5guta + name: mynewstream + partitions: 4 + +- name: Update stream using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_streaming_stream: + name: mynewstream + stream_pool_id: ocid1.streampool.realm.region.zxcvbn432765 + freeform_tags: {'Department': 'Finance'} + defined_tags: {'Operations': {'CostCenter': 'US'}} + +- name: Update stream + oci_streaming_stream: + stream_id: ocid1.stream.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete stream + oci_streaming_stream: + stream_id: ocid1.stream.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete stream using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_streaming_stream: + name: mynewstream + state: absent + +""" + +RETURN = """ +stream: + description: + - Details of the Stream resource acted upon by the current operation + returned: on success + type: complex + contains: + name: + description: + - The name of the stream. Avoid entering confidential information. + - "Example: `TelemetryEvents`" + returned: on success + type: string + sample: TelemetryEvents + id: + description: + - The OCID of the stream. + returned: on success + type: string + sample: ocid1.stream.realm.region.mnopqr789 + partitions: + description: + - The number of partitions in the stream. + returned: on success + type: int + sample: 10 + retention_in_hours: + description: + - The retention period of the stream, in hours. This property is read-only. + returned: on success + type: int + sample: 24 + compartment_id: + description: + - The OCID of the stream. + returned: on success + type: string + sample: ocid1.compinstance.realm.region.zxcvbn432765 + stream_pool_id: + description: + - The OCID of the stream pool that contains the stream. + returned: on success + type: string + sample: ocid1.streampool.realm.region.zxcvbn432765 + lifecycle_state: + description: + - The current state of the stream. + returned: on success + type: string + sample: CREATING + lifecycle_state_details: + description: + - Any additional details about the current state of the stream. + returned: on success + type: string + sample: lifecycle_state_details_example + time_created: + description: + - The date and time the stream was created, expressed in in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339) timestamp format. + - "Example: `2018-04-20T00:00:07.405Z`" + returned: on success + type: string + sample: 2018-04-20T00:00:07.405Z + messages_endpoint: + description: + - The endpoint to use when creating the StreamClient to consume or publish messages in the stream. + If the associated stream pool is private, the endpoint is also private and can only be accessed from inside the stream pool's associated + subnet. + returned: on success + type: string + sample: messages_endpoint_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross- + compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}'" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: { + "name": "TelemetryEvents", + "id": "ocid1.stream.realm.region.mnopqr789", + "partitions": 10, + "retention_in_hours": 24, + "compartment_id": "ocid1.compinstance.realm.region.zxcvbn432765", + "stream_pool_id": "ocid1.streampool.realm.region.zxcvbn432765", + "lifecycle_state": "CREATING", + "lifecycle_state_details": "lifecycle_state_details_example", + "time_created": "2018-04-20T00:00:07.405Z", + "messages_endpoint": "messages_endpoint_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.streaming import StreamAdminClient + from oci.streaming.models import CreateStreamDetails + from oci.streaming.models import UpdateStreamDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class StreamHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "stream_id" + + def get_module_resource_id(self): + return self.module.params.get("stream_id") + + def get_get_fn(self): + return self.client.get_stream + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_stream, stream_id=self.module.params.get("stream_id"), + ) + + def get_required_kwargs_for_list(self): + return dict() + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ( + ["compartment_id", "name"] + if self._use_name_as_identifier() + else ["compartment_id", "stream_pool_id", "name"] + ) + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources(self.client.list_streams, **kwargs) + + def get_create_model_class(self): + return CreateStreamDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_stream, + call_fn_args=(), + call_fn_kwargs=dict(create_stream_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateStreamDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_stream, + call_fn_args=(), + call_fn_kwargs=dict( + stream_id=self.module.params.get("stream_id"), + update_stream_details=update_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_stream, + call_fn_args=(), + call_fn_kwargs=dict(stream_id=self.module.params.get("stream_id"),), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +StreamHelperCustom = get_custom_class("StreamHelperCustom") + + +class ResourceHelper(StreamHelperCustom, StreamHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + name=dict(type="str"), + partitions=dict(type="int"), + compartment_id=dict(type="str"), + stream_pool_id=dict(type="str"), + retention_in_hours=dict(type="int"), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + stream_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="stream", + service_client_class=StreamAdminClient, + namespace="streaming", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_streaming_stream_facts.py b/plugins/modules/oci_streaming_stream_facts.py new file mode 100644 index 0000000000..a53e3608e0 --- /dev/null +++ b/plugins/modules/oci_streaming_stream_facts.py @@ -0,0 +1,308 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_streaming_stream_facts +short_description: Fetches details about one or multiple Stream resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple Stream resources in Oracle Cloud Infrastructure + - Lists the streams in the given compartment id. + If the compartment id is specified, it will list streams in the compartment, regardless of their stream pool. + If the stream pool id is specified, the action will be scoped to that stream pool. + The compartment id and stream pool id cannot be specified at the same time. + - If I(stream_id) is specified, the details of a single Stream will be returned. +version_added: "2.5" +options: + stream_id: + description: + - The OCID of the stream. + - Required to get a specific stream. + type: str + aliases: ["id"] + compartment_id: + description: + - The OCID of the compartment. Is exclusive with the `streamPoolId` parameter. One of them is required. + type: str + stream_pool_id: + description: + - The OCID of the stream pool. Is exclusive with the `compartmentId` parameter. One of them is required. + type: str + id: + description: + - A filter to return only resources that match the given ID exactly. + type: str + name: + description: + - A filter to return only resources that match the given name exactly. + type: str + sort_by: + description: + - The field to sort by. You can provide no more than one sort order. By default, `TIMECREATED` sorts results in descending order and `NAME` sorts + results in ascending order. + type: str + choices: + - "NAME" + - "TIMECREATED" + sort_order: + description: + - The sort order to use, either 'asc' or 'desc'. + type: str + choices: + - "ASC" + - "DESC" + lifecycle_state: + description: + - A filter to only return resources that match the given lifecycle state. The state value is case-insensitive. + type: str + choices: + - "CREATING" + - "ACTIVE" + - "DELETING" + - "DELETED" + - "FAILED" + - "UPDATING" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List streams + oci_streaming_stream_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific stream + oci_streaming_stream_facts: + stream_id: ocid1.stream.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +streams: + description: + - List of Stream resources + returned: on success + type: complex + contains: + name: + description: + - The name of the stream. Avoid entering confidential information. + - "Example: `TelemetryEvents`" + returned: on success + type: string + sample: TelemetryEvents + id: + description: + - The OCID of the stream. + returned: on success + type: string + sample: ocid1.stream.realm.region.mnopqr789 + partitions: + description: + - The number of partitions in the stream. + returned: on success + type: int + sample: 10 + retention_in_hours: + description: + - The retention period of the stream, in hours. This property is read-only. + returned: on success + type: int + sample: 24 + compartment_id: + description: + - The OCID of the stream. + returned: on success + type: string + sample: ocid1.compinstance.realm.region.zxcvbn432765 + stream_pool_id: + description: + - The OCID of the stream pool that contains the stream. + returned: on success + type: string + sample: ocid1.streampool.realm.region.zxcvbn432765 + lifecycle_state: + description: + - The current state of the stream. + returned: on success + type: string + sample: CREATING + lifecycle_state_details: + description: + - Any additional details about the current state of the stream. + returned: on success + type: string + sample: lifecycle_state_details_example + time_created: + description: + - The date and time the stream was created, expressed in in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339) timestamp format. + - "Example: `2018-04-20T00:00:07.405Z`" + returned: on success + type: string + sample: 2018-04-20T00:00:07.405Z + messages_endpoint: + description: + - The endpoint to use when creating the StreamClient to consume or publish messages in the stream. + If the associated stream pool is private, the endpoint is also private and can only be accessed from inside the stream pool's associated + subnet. + returned: on success + type: string + sample: messages_endpoint_example + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross- + compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}'" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: [{ + "name": "TelemetryEvents", + "id": "ocid1.stream.realm.region.mnopqr789", + "partitions": 10, + "retention_in_hours": 24, + "compartment_id": "ocid1.compinstance.realm.region.zxcvbn432765", + "stream_pool_id": "ocid1.streampool.realm.region.zxcvbn432765", + "lifecycle_state": "CREATING", + "lifecycle_state_details": "lifecycle_state_details_example", + "time_created": "2018-04-20T00:00:07.405Z", + "messages_endpoint": "messages_endpoint_example", + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.streaming import StreamAdminClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class StreamFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "stream_id", + ] + + def get_required_params_for_list(self): + return [] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_stream, stream_id=self.module.params.get("stream_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "compartment_id", + "stream_pool_id", + "id", + "name", + "sort_by", + "sort_order", + "lifecycle_state", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_streams, **optional_kwargs + ) + + +StreamFactsHelperCustom = get_custom_class("StreamFactsHelperCustom") + + +class ResourceFactsHelper(StreamFactsHelperCustom, StreamFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + stream_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + stream_pool_id=dict(type="str"), + id=dict(type="str"), + name=dict(type="str"), + sort_by=dict(type="str", choices=["NAME", "TIMECREATED"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + lifecycle_state=dict( + type="str", + choices=[ + "CREATING", + "ACTIVE", + "DELETING", + "DELETED", + "FAILED", + "UPDATING", + ], + ), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="stream", + service_client_class=StreamAdminClient, + namespace="streaming", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(streams=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_streaming_stream_pool.py b/plugins/modules/oci_streaming_stream_pool.py new file mode 100644 index 0000000000..c71f7a42a2 --- /dev/null +++ b/plugins/modules/oci_streaming_stream_pool.py @@ -0,0 +1,538 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_streaming_stream_pool +short_description: Manage a StreamPool resource in Oracle Cloud Infrastructure +description: + - This module allows the user to create, update and delete a StreamPool resource in Oracle Cloud Infrastructure + - For I(state=present), starts the provisioning of a new stream pool. + To track the progress of the provisioning, you can periodically call GetStreamPool. + In the response, the `lifecycleState` parameter of the object tells you its current state. +version_added: "2.9" +author: Oracle (@oracle) +options: + compartment_id: + description: + - The OCID of the compartment that contains the stream. + - Required for create using I(state=present). + - Required for update when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + - Required for delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + name: + description: + - The name of the stream pool. Avoid entering confidential information. + - "Example: `MyStreamPool`" + - Required for create using I(state=present). + - Required for update, delete when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is set. + type: str + kafka_settings: + description: + - "" + type: dict + suboptions: + bootstrap_servers: + description: + - Bootstrap servers. + type: str + auto_create_topics_enable: + description: + - Enable auto creation of topic on the server. + type: bool + log_retention_hours: + description: + - The number of hours to keep a log file before deleting it (in hours). + type: int + num_partitions: + description: + - The default number of log partitions per topic. + type: int + custom_encryption_key_details: + description: + - "" + type: dict + suboptions: + kms_key_id: + description: + - Custom Encryption Key (Master Key) ocid. + type: str + required: true + private_endpoint_details: + description: + - "" + type: dict + suboptions: + subnet_id: + description: + - If specified, the stream pool will be private and only accessible from inside that subnet. + Producing-to and consuming-from a stream inside a private stream pool can also only be done from inside the subnet. + That value cannot be changed. + type: str + private_endpoint_ip: + description: + - The optional private IP you want to be associated with your private stream pool. + That parameter can only be specified when the subnetId parameter is set. It cannot be changed. + The private IP needs to be part of the CIDR range of the specified subnetId or the creation will fail. + If not specified a random IP inside the subnet will be chosen. + After the stream pool is created, a custom FQDN, pointing to this private IP, is created. + The FQDN is then used to access the service instead of the private IP. + type: str + nsg_ids: + description: + - The optional list of network security groups to be used with the private endpoint of the stream pool. + That value cannot be changed. + type: list + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair that is applied with no predefined name, type, or namespace. Exists for + cross-compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + type: dict + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}`" + type: dict + stream_pool_id: + description: + - The OCID of the stream pool. + - Required for update using I(state=present) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + - Required for delete using I(state=absent) when environment variable C(OCI_USE_NAME_AS_IDENTIFIER) is not set. + type: str + aliases: ["id"] + state: + description: + - The state of the StreamPool. + - Use I(state=present) to create or update a StreamPool. + - Use I(state=absent) to delete a StreamPool. + type: str + required: false + default: 'present' + choices: ["present", "absent"] +extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] +""" + +EXAMPLES = """ +- name: Create stream_pool + oci_streaming_stream_pool: + compartment_id: ocid1.tenancy.oc1..exampleasgadvsw7l6cvb4fhssurjqs4irbkzma3wc2fauxv4novazj5guta + name: MyStreamPool + +- name: Update stream_pool using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_streaming_stream_pool: + kafka_settings: + auto_create_topics_enable: true + log_retention_hours: 24 + num_partitions: 1 + +- name: Update stream_pool + oci_streaming_stream_pool: + stream_pool_id: ocid1.streampool.oc1..xxxxxxEXAMPLExxxxxx + +- name: Delete stream_pool + oci_streaming_stream_pool: + stream_pool_id: ocid1.streampool.oc1..xxxxxxEXAMPLExxxxxx + state: absent + +- name: Delete stream_pool using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set) + oci_streaming_stream_pool: + compartment_id: ocid1.tenancy.oc1..exampleasgadvsw7l6cvb4fhssurjqs4irbkzma3wc2fauxv4novazj5guta + name: MyStreamPool + state: absent + +""" + +RETURN = """ +stream_pool: + description: + - Details of the StreamPool resource acted upon by the current operation + returned: on success + type: complex + contains: + id: + description: + - The OCID of the stream pool. + returned: on success + type: string + sample: ocid1.streampool.realm.region.mnopqr789 + compartment_id: + description: + - Compartment OCID that the pool belongs to. + returned: on success + type: string + sample: ocid1.compartment.oc1..aaaaaaaa2byuam5ewxzrcs2iqzh7okx84jae6j4uhkih5wdbrkkwuxv3qgpa + name: + description: + - The name of the stream pool. + returned: on success + type: string + sample: MyStreamPool + lifecycle_state: + description: + - The current state of the stream pool. + returned: on success + type: string + sample: CREATING + lifecycle_state_details: + description: + - Any additional details about the current state of the stream. + returned: on success + type: string + sample: lifecycle_state_details_example + time_created: + description: + - The date and time the stream pool was created, expressed in in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339) timestamp format. + - "Example: `2018-04-20T00:00:07.405Z`" + returned: on success + type: string + sample: 2018-04-20T00:00:07.405Z + kafka_settings: + description: + - "" + returned: on success + type: complex + contains: + bootstrap_servers: + description: + - Bootstrap servers. + returned: on success + type: string + sample: bootstrap_servers_example + auto_create_topics_enable: + description: + - Enable auto creation of topic on the server. + returned: on success + type: bool + sample: true + log_retention_hours: + description: + - The number of hours to keep a log file before deleting it (in hours). + returned: on success + type: int + sample: 56 + num_partitions: + description: + - The default number of log partitions per topic. + returned: on success + type: int + sample: 56 + custom_encryption_key: + description: + - "" + returned: on success + type: complex + contains: + kms_key_id: + description: + - Custom Encryption Key (Master Key) ocid. + returned: on success + type: string + sample: ocid1.kmskey.oc1..xxxxxxEXAMPLExxxxxx + key_state: + description: + - Life cycle State of the custom key + returned: on success + type: string + sample: ACTIVE + is_private: + description: + - True if the stream pool is private, false otherwise. + If the stream pool is private, the streams inside the stream pool can only be accessed from inside the associated subnetId. + returned: on success + type: bool + sample: true + endpoint_fqdn: + description: + - The FQDN used to access the streams inside the stream pool (same FQDN as the messagesEndpoint attribute of a + L(Stream,https://docs.cloud.oracle.com/#/en/streaming/20180418/Stream) object). + If the stream pool is private, the FQDN is customized and can only be accessed from inside the associated subnetId, otherwise the FQDN is + publicly resolvable. + Depending on which protocol you attempt to use, you need to either prepend https or append the Kafka port. + returned: on success + type: string + sample: endpoint_fqdn_example + private_endpoint_settings: + description: + - "" + returned: on success + type: complex + contains: + subnet_id: + description: + - The subnet id from which the private stream pool can be accessed. + Trying to access the streams from another network location will result in an error. + returned: on success + type: string + sample: ocid1.subnet.realm.region.zxcvbn432765 + private_endpoint_ip: + description: + - "The private IP associated with the stream pool in the associated subnetId. + The stream pool's FQDN resolves to that IP and should be used - instead of the private IP - in order to not trigger any TLS issues." + returned: on success + type: string + sample: 10.0.0.5 + nsg_ids: + description: + - The optional list of network security groups that are associated with the private endpoint of the stream pool. + returned: on success + type: list + sample: [] + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross- + compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}'" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: { + "id": "ocid1.streampool.realm.region.mnopqr789", + "compartment_id": "ocid1.compartment.oc1..aaaaaaaa2byuam5ewxzrcs2iqzh7okx84jae6j4uhkih5wdbrkkwuxv3qgpa", + "name": "MyStreamPool", + "lifecycle_state": "CREATING", + "lifecycle_state_details": "lifecycle_state_details_example", + "time_created": "2018-04-20T00:00:07.405Z", + "kafka_settings": { + "bootstrap_servers": "bootstrap_servers_example", + "auto_create_topics_enable": true, + "log_retention_hours": 56, + "num_partitions": 56 + }, + "custom_encryption_key": { + "kms_key_id": "ocid1.kmskey.oc1..xxxxxxEXAMPLExxxxxx", + "key_state": "ACTIVE" + }, + "is_private": true, + "endpoint_fqdn": "endpoint_fqdn_example", + "private_endpoint_settings": { + "subnet_id": "ocid1.subnet.realm.region.zxcvbn432765", + "private_endpoint_ip": "10.0.0.5", + "nsg_ids": [] + }, + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import ( + oci_common_utils, + oci_wait_utils, +) +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceHelperBase, + get_custom_class, +) + +try: + from oci.streaming import StreamAdminClient + from oci.streaming.models import CreateStreamPoolDetails + from oci.streaming.models import UpdateStreamPoolDetails + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class StreamPoolHelperGen(OCIResourceHelperBase): + """Supported operations: create, update, get, list and delete""" + + def get_module_resource_id_param(self): + return "stream_pool_id" + + def get_module_resource_id(self): + return self.module.params.get("stream_pool_id") + + def get_get_fn(self): + return self.client.get_stream_pool + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_stream_pool, + stream_pool_id=self.module.params.get("stream_pool_id"), + ) + + def get_required_kwargs_for_list(self): + required_list_method_params = [ + "compartment_id", + ] + + return dict( + (param, self.module.params[param]) for param in required_list_method_params + ) + + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["name"] + + return dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + and ( + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) + ) + ) + + def list_resources(self): + + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + return oci_common_utils.list_all_resources( + self.client.list_stream_pools, **kwargs + ) + + def get_create_model_class(self): + return CreateStreamPoolDetails + + def create_resource(self): + create_details = self.get_create_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.create_stream_pool, + call_fn_args=(), + call_fn_kwargs=dict(create_stream_pool_details=create_details,), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.CREATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def get_update_model_class(self): + return UpdateStreamPoolDetails + + def update_resource(self): + update_details = self.get_update_model() + return oci_wait_utils.call_and_wait( + call_fn=self.client.update_stream_pool, + call_fn_args=(), + call_fn_kwargs=dict( + stream_pool_id=self.module.params.get("stream_pool_id"), + update_stream_pool_details=update_details, + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.UPDATE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_active_states(), + ) + + def delete_resource(self): + return oci_wait_utils.call_and_wait( + call_fn=self.client.delete_stream_pool, + call_fn_args=(), + call_fn_kwargs=dict( + stream_pool_id=self.module.params.get("stream_pool_id"), + ), + waiter_type=oci_wait_utils.LIFECYCLE_STATE_WAITER_KEY, + operation=oci_common_utils.DELETE_OPERATION_KEY, + waiter_client=self.client, + resource_helper=self, + wait_for_states=self.get_resource_terminated_states(), + ) + + +StreamPoolHelperCustom = get_custom_class("StreamPoolHelperCustom") + + +class ResourceHelper(StreamPoolHelperCustom, StreamPoolHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec( + supports_create=True, supports_wait=True + ) + module_args.update( + dict( + compartment_id=dict(type="str"), + name=dict(type="str"), + kafka_settings=dict( + type="dict", + options=dict( + bootstrap_servers=dict(type="str"), + auto_create_topics_enable=dict(type="bool"), + log_retention_hours=dict(type="int"), + num_partitions=dict(type="int"), + ), + ), + custom_encryption_key_details=dict( + type="dict", options=dict(kms_key_id=dict(type="str", required=True)) + ), + private_endpoint_details=dict( + type="dict", + options=dict( + subnet_id=dict(type="str"), + private_endpoint_ip=dict(type="str"), + nsg_ids=dict(type="list"), + ), + ), + freeform_tags=dict(type="dict"), + defined_tags=dict(type="dict"), + stream_pool_id=dict(aliases=["id"], type="str"), + state=dict(type="str", default="present", choices=["present", "absent"]), + ) + ) + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_helper = ResourceHelper( + module=module, + resource_type="stream_pool", + service_client_class=StreamAdminClient, + namespace="streaming", + ) + + result = dict(changed=False) + + if resource_helper.is_delete_using_name(): + result = resource_helper.delete_using_name() + elif resource_helper.is_delete(): + result = resource_helper.delete() + elif resource_helper.is_update_using_name(): + result = resource_helper.update_using_name() + elif resource_helper.is_update(): + result = resource_helper.update() + elif resource_helper.is_create(): + result = resource_helper.create() + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_streaming_stream_pool_facts.py b/plugins/modules/oci_streaming_stream_pool_facts.py new file mode 100644 index 0000000000..83cab86a85 --- /dev/null +++ b/plugins/modules/oci_streaming_stream_pool_facts.py @@ -0,0 +1,381 @@ +#!/usr/bin/python +# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# Apache License v2.0 +# See LICENSE.TXT for details. +# GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN + + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "community", +} + +DOCUMENTATION = """ +--- +module: oci_streaming_stream_pool_facts +short_description: Fetches details about one or multiple StreamPool resources in Oracle Cloud Infrastructure +description: + - Fetches details about one or multiple StreamPool resources in Oracle Cloud Infrastructure + - List the stream pools for a given compartment ID. + - If I(stream_pool_id) is specified, the details of a single StreamPool will be returned. +version_added: "2.5" +options: + stream_pool_id: + description: + - The OCID of the stream pool. + - Required to get a specific stream_pool. + type: str + aliases: ["id"] + compartment_id: + description: + - The OCID of the compartment. + - Required to list multiple stream_pools. + type: str + id: + description: + - A filter to return only resources that match the given ID exactly. + type: str + name: + description: + - A filter to return only resources that match the given name exactly. + type: str + sort_by: + description: + - The field to sort by. You can provide no more than one sort order. By default, `TIMECREATED` sorts results in descending order and `NAME` sorts + results in ascending order. + type: str + choices: + - "NAME" + - "TIMECREATED" + sort_order: + description: + - The sort order to use, either 'asc' or 'desc'. + type: str + choices: + - "ASC" + - "DESC" + lifecycle_state: + description: + - A filter to only return resources that match the given lifecycle state. The state value is case-insensitive. + type: str + choices: + - "CREATING" + - "ACTIVE" + - "DELETING" + - "DELETED" + - "FAILED" + - "UPDATING" +author: Oracle (@oracle) +extends_documentation_fragment: [ oracle.oci.oracle ] +""" + +EXAMPLES = """ +- name: List stream_pools + oci_streaming_stream_pool_facts: + compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx + +- name: Get a specific stream_pool + oci_streaming_stream_pool_facts: + stream_pool_id: ocid1.streampool.oc1..xxxxxxEXAMPLExxxxxx + +""" + +RETURN = """ +stream_pools: + description: + - List of StreamPool resources + returned: on success + type: complex + contains: + id: + description: + - The OCID of the stream pool. + returned: on success + type: string + sample: ocid1.streampool.realm.region.mnopqr789 + compartment_id: + description: + - Compartment OCID that the pool belongs to. + returned: on success + type: string + sample: ocid1.compartment.oc1..aaaaaaaa2byuam5ewxzrcs2iqzh7okx84jae6j4uhkih5wdbrkkwuxv3qgpa + name: + description: + - The name of the stream pool. + returned: on success + type: string + sample: MyStreamPool + lifecycle_state: + description: + - The current state of the stream pool. + returned: on success + type: string + sample: CREATING + lifecycle_state_details: + description: + - Any additional details about the current state of the stream. + returned: on success + type: string + sample: lifecycle_state_details_example + time_created: + description: + - The date and time the stream pool was created, expressed in in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339) timestamp format. + - "Example: `2018-04-20T00:00:07.405Z`" + returned: on success + type: string + sample: 2018-04-20T00:00:07.405Z + kafka_settings: + description: + - "" + returned: on success + type: complex + contains: + bootstrap_servers: + description: + - Bootstrap servers. + returned: on success + type: string + sample: bootstrap_servers_example + auto_create_topics_enable: + description: + - Enable auto creation of topic on the server. + returned: on success + type: bool + sample: true + log_retention_hours: + description: + - The number of hours to keep a log file before deleting it (in hours). + returned: on success + type: int + sample: 56 + num_partitions: + description: + - The default number of log partitions per topic. + returned: on success + type: int + sample: 56 + custom_encryption_key: + description: + - "" + returned: on success + type: complex + contains: + kms_key_id: + description: + - Custom Encryption Key (Master Key) ocid. + returned: on success + type: string + sample: ocid1.kmskey.oc1..xxxxxxEXAMPLExxxxxx + key_state: + description: + - Life cycle State of the custom key + returned: on success + type: string + sample: ACTIVE + is_private: + description: + - True if the stream pool is private, false otherwise. + If the stream pool is private, the streams inside the stream pool can only be accessed from inside the associated subnetId. + returned: on success + type: bool + sample: true + endpoint_fqdn: + description: + - The FQDN used to access the streams inside the stream pool (same FQDN as the messagesEndpoint attribute of a + L(Stream,https://docs.cloud.oracle.com/#/en/streaming/20180418/Stream) object). + If the stream pool is private, the FQDN is customized and can only be accessed from inside the associated subnetId, otherwise the FQDN is + publicly resolvable. + Depending on which protocol you attempt to use, you need to either prepend https or append the Kafka port. + returned: on success + type: string + sample: endpoint_fqdn_example + private_endpoint_settings: + description: + - "" + returned: on success + type: complex + contains: + subnet_id: + description: + - The subnet id from which the private stream pool can be accessed. + Trying to access the streams from another network location will result in an error. + returned: on success + type: string + sample: ocid1.subnet.realm.region.zxcvbn432765 + private_endpoint_ip: + description: + - "The private IP associated with the stream pool in the associated subnetId. + The stream pool's FQDN resolves to that IP and should be used - instead of the private IP - in order to not trigger any TLS issues." + returned: on success + type: string + sample: 10.0.0.5 + nsg_ids: + description: + - The optional list of network security groups that are associated with the private endpoint of the stream pool. + returned: on success + type: list + sample: [] + freeform_tags: + description: + - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross- + compatibility only. + For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Department\\": \\"Finance\\"}`" + returned: on success + type: dict + sample: {'Department': 'Finance'} + defined_tags: + description: + - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see L(Resource + Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm). + - "Example: `{\\"Operations\\": {\\"CostCenter\\": \\"42\\"}}'" + returned: on success + type: dict + sample: {'Operations': {'CostCenter': 'US'}} + sample: [{ + "id": "ocid1.streampool.realm.region.mnopqr789", + "compartment_id": "ocid1.compartment.oc1..aaaaaaaa2byuam5ewxzrcs2iqzh7okx84jae6j4uhkih5wdbrkkwuxv3qgpa", + "name": "MyStreamPool", + "lifecycle_state": "CREATING", + "lifecycle_state_details": "lifecycle_state_details_example", + "time_created": "2018-04-20T00:00:07.405Z", + "kafka_settings": { + "bootstrap_servers": "bootstrap_servers_example", + "auto_create_topics_enable": true, + "log_retention_hours": 56, + "num_partitions": 56 + }, + "custom_encryption_key": { + "kms_key_id": "ocid1.kmskey.oc1..xxxxxxEXAMPLExxxxxx", + "key_state": "ACTIVE" + }, + "is_private": true, + "endpoint_fqdn": "endpoint_fqdn_example", + "private_endpoint_settings": { + "subnet_id": "ocid1.subnet.realm.region.zxcvbn432765", + "private_endpoint_ip": "10.0.0.5", + "nsg_ids": [] + }, + "freeform_tags": {'Department': 'Finance'}, + "defined_tags": {'Operations': {'CostCenter': 'US'}} + }] +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils +from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import ( + OCIResourceFactsHelperBase, + get_custom_class, +) + +try: + from oci.streaming import StreamAdminClient + + HAS_OCI_PY_SDK = True +except ImportError: + HAS_OCI_PY_SDK = False + + +class StreamPoolFactsHelperGen(OCIResourceFactsHelperBase): + """Supported operations: get, list""" + + def get_required_params_for_get(self): + return [ + "stream_pool_id", + ] + + def get_required_params_for_list(self): + return [ + "compartment_id", + ] + + def get_resource(self): + return oci_common_utils.call_with_backoff( + self.client.get_stream_pool, + stream_pool_id=self.module.params.get("stream_pool_id"), + ) + + def list_resources(self): + optional_list_method_params = [ + "id", + "name", + "sort_by", + "sort_order", + "lifecycle_state", + ] + optional_kwargs = dict( + (param, self.module.params[param]) + for param in optional_list_method_params + if self.module.params.get(param) is not None + ) + return oci_common_utils.list_all_resources( + self.client.list_stream_pools, + compartment_id=self.module.params.get("compartment_id"), + **optional_kwargs + ) + + +StreamPoolFactsHelperCustom = get_custom_class("StreamPoolFactsHelperCustom") + + +class ResourceFactsHelper(StreamPoolFactsHelperCustom, StreamPoolFactsHelperGen): + pass + + +def main(): + module_args = oci_common_utils.get_common_arg_spec() + module_args.update( + dict( + stream_pool_id=dict(aliases=["id"], type="str"), + compartment_id=dict(type="str"), + id=dict(type="str"), + name=dict(type="str"), + sort_by=dict(type="str", choices=["NAME", "TIMECREATED"]), + sort_order=dict(type="str", choices=["ASC", "DESC"]), + lifecycle_state=dict( + type="str", + choices=[ + "CREATING", + "ACTIVE", + "DELETING", + "DELETED", + "FAILED", + "UPDATING", + ], + ), + ) + ) + + module = AnsibleModule(argument_spec=module_args) + + if not HAS_OCI_PY_SDK: + module.fail_json(msg="oci python sdk required for this module.") + + resource_facts_helper = ResourceFactsHelper( + module=module, + resource_type="stream_pool", + service_client_class=StreamAdminClient, + namespace="streaming", + ) + + result = [] + + if resource_facts_helper.is_get(): + result = [resource_facts_helper.get()] + elif resource_facts_helper.is_list(): + result = resource_facts_helper.list() + else: + resource_facts_helper.fail() + + module.exit_json(stream_pools=result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/oci_vault_secret.py b/plugins/modules/oci_vault_secret.py index 64712489c8..7b63db6807 100644 --- a/plugins/modules/oci_vault_secret.py +++ b/plugins/modules/oci_vault_secret.py @@ -26,7 +26,8 @@ - For I(state=present), creates a new secret according to the details of the request. - This operation is not supported by the Oracle Cloud Infrastructure Terraform Provider. - "This resource has the following action operations in the M(oci_secret_actions) module: cancel_secret_deletion, schedule_secret_deletion." -version_added: "2.5" +version_added: "2.9" +author: Oracle (@oracle) options: compartment_id: description: @@ -166,10 +167,6 @@ required: false default: 'present' choices: ["present"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_creatable_resource, oracle.oci.oracle_wait_options ] """ @@ -412,31 +409,36 @@ def get_resource(self): self.client.get_secret, secret_id=self.module.params.get("secret_id"), ) - def list_resources(self): + def get_required_kwargs_for_list(self): required_list_method_params = [ "compartment_id", ] - optional_list_method_params = [ - "vault_id", - ] - - required_kwargs = dict( + return dict( (param, self.module.params[param]) for param in required_list_method_params ) - optional_kwargs = dict( + def get_optional_kwargs_for_list(self): + optional_list_method_params = ["vault_id"] + + return dict( (param, self.module.params[param]) for param in optional_list_method_params if self.module.params.get(param) is not None and ( - not self.module.params.get("key_by") - or param in self.module.params.get("key_by") + self._use_name_as_identifier() + or ( + not self.module.params.get("key_by") + or param in self.module.params.get("key_by") + ) ) ) - kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) + def list_resources(self): + required_kwargs = self.get_required_kwargs_for_list() + optional_kwargs = self.get_optional_kwargs_for_list() + kwargs = oci_common_utils.merge_dicts(required_kwargs, optional_kwargs) return oci_common_utils.list_all_resources(self.client.list_secrets, **kwargs) def get_create_model_class(self): diff --git a/plugins/modules/oci_vault_secret_actions.py b/plugins/modules/oci_vault_secret_actions.py index 8fe03f3d8c..a2d2abe06d 100644 --- a/plugins/modules/oci_vault_secret_actions.py +++ b/plugins/modules/oci_vault_secret_actions.py @@ -46,11 +46,10 @@ - The action to perform on the Secret. type: str required: true - choices: ["cancel_secret_deletion", "schedule_secret_deletion"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "cancel_secret_deletion" + - "schedule_secret_deletion" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_vault_secret_facts.py b/plugins/modules/oci_vault_secret_facts.py index 0d2660d93a..7b5d0be76c 100644 --- a/plugins/modules/oci_vault_secret_facts.py +++ b/plugins/modules/oci_vault_secret_facts.py @@ -75,10 +75,7 @@ - "PENDING_DELETION" - "CANCELLING_DELETION" - "FAILED" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_vault_secret_version_actions.py b/plugins/modules/oci_vault_secret_version_actions.py index da3c13b526..3574b98253 100644 --- a/plugins/modules/oci_vault_secret_version_actions.py +++ b/plugins/modules/oci_vault_secret_version_actions.py @@ -50,11 +50,10 @@ - The action to perform on the SecretVersion. type: str required: true - choices: ["cancel_secret_version_deletion", "schedule_secret_version_deletion"] -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) + choices: + - "cancel_secret_version_deletion" + - "schedule_secret_version_deletion" +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle ] """ diff --git a/plugins/modules/oci_vault_secret_version_facts.py b/plugins/modules/oci_vault_secret_version_facts.py index 8845599b49..dd538793da 100644 --- a/plugins/modules/oci_vault_secret_version_facts.py +++ b/plugins/modules/oci_vault_secret_version_facts.py @@ -51,10 +51,7 @@ choices: - "ASC" - "DESC" -author: - - Manoj Meda (@manojmeda) - - Mike Ross (@mross22) - - Nabeel Al-Saber (@nalsaber) +author: Oracle (@oracle) extends_documentation_fragment: [ oracle.oci.oracle, oracle.oci.oracle_name_option ] """ diff --git a/samples/database/autonomous_database/sample.yaml b/samples/database/autonomous_database/sample.yaml index 7465954f6b..206d34c058 100644 --- a/samples/database/autonomous_database/sample.yaml +++ b/samples/database/autonomous_database/sample.yaml @@ -18,12 +18,12 @@ # variables ######################################### compartment_ocid: "{{ lookup('env', 'SAMPLE_COMPARTMENT_OCID') }}" - cpu_core_count: "{{ lookup('env', 'SAMPLE_CPU_CORE_COUNT') }}" # sample value, cpu_core_count: 1 - display_name: "{{ lookup('env', 'SAMPLE_DB_DISPLAY_NAME') }}" # sample value, display_name: 'sample_autonomous_db' - admin_password: "{{ lookup('env', 'SAMPLE_ADMIN_PASSWORD') }}" # sample value, admin_password: 'BEstr0ng_#11' - db_name: "{{ lookup('env', 'SAMPLE_DB_NAME') }}" # sample value, db_name: 'autonomousdb' (Maximum 14 alphanumeric characters) - data_storage_size_in_tbs: "{{ lookup('env', 'SAMPLE_DATA_STORAGE_SIZE_IN_TBS') }}" # sample value, data_storage_size_in_tbs: 1 - license_model: "{{ lookup('env', 'SAMPLE_LICENSE_MODEL') }}" #sample value, license_model: 'LICENSE_INCLUDED' + cpu_core_count: "{{ lookup('env', 'SAMPLE_CPU_CORE_COUNT') | default(1, true) }}" # sample value, cpu_core_count: 1 + display_name: "{{ lookup('env', 'SAMPLE_DB_DISPLAY_NAME') | default('sample_autonomous_db', true) }}" # sample value, display_name: 'sample_autonomous_db' + admin_password: "{{ lookup('env', 'SAMPLE_ADMIN_PASSWORD') | default('BEstr0ng_#11', true) }}" # sample value, admin_password: 'BEstr0ng_#11' + db_name: "{{ lookup('env', 'SAMPLE_DB_NAME') | default('autonomousdb', true) }}" # sample value, db_name: 'autonomousdb' (Maximum 14 alphanumeric characters) + data_storage_size_in_tbs: "{{ lookup('env', 'SAMPLE_DATA_STORAGE_SIZE_IN_TBS') | default(1, true) }}" # sample value, data_storage_size_in_tbs: 1 + license_model: "{{ lookup('env', 'SAMPLE_LICENSE_MODEL') | default('LICENSE_INCLUDED', true) }}" #sample value, license_model: 'LICENSE_INCLUDED' tasks: - block: @@ -34,12 +34,6 @@ when: item not in ansible_env with_items: - "SAMPLE_COMPARTMENT_OCID" - - "SAMPLE_CPU_CORE_COUNT" - - "SAMPLE_DB_DISPLAY_NAME" - - "SAMPLE_ADMIN_PASSWORD" - - "SAMPLE_DB_NAME" - - "SAMPLE_DATA_STORAGE_SIZE_IN_TBS" - - "SAMPLE_LICENSE_MODEL" - name: Create a new Autonomous Database oci_database_autonomous_database: diff --git a/samples/database/autonomous_database/teardown.yaml b/samples/database/autonomous_database/teardown.yaml index 678c0be884..2809b2e096 100644 --- a/samples/database/autonomous_database/teardown.yaml +++ b/samples/database/autonomous_database/teardown.yaml @@ -5,15 +5,21 @@ # Apache License v2.0 # See LICENSE.TXT for details. +# NOTE: Running `teardown.yaml` alone will not delete the autonomous db created in `sample.yaml`. This playbook uses the +# `autonomous_database_id` parameter that is being set in `sample.yaml`. Please provide the database_id of a database that +# you intend to delete. + # Delete Autonomous Database - name: Delete Autonomous Database oci_database_autonomous_database: autonomous_database_id: "{{ autonomous_database_id }}" state: 'absent' register: result + when: autonomous_database_id is defined - name: Assert that specified Autonomous Database is deleted assert: that: - result.changed == True - result.autonomous_database.display_name == display_name + when: autonomous_database_id is defined